繁体   English   中英

将两个bash命令合并为一个快捷方式提示

[英]combine two bash commands into a one shortcut prompt

我对bash不太满意,但是我想写一个快捷方式,例如'opendev',它可以在浏览器中打开一个url,并打开我当前所在的git主题分支。 (仅需要在os x上工作)。 灵感来自heroku CTL的“ heroku open”。

我在这里有基本知识,但是我不确定如何连接它们。

#This launches my default browser and opens a url
open http://branchname.dev.foobar.com
#this returns the current git topic branch name  i'm working on
git branch | grep "*" | sed "s/* //"

因为我失败了,所以任何帮助都将是惊人的。

将以下内容放入您的.bashrc或类似文件中:

opendev() {
    open http://$(git branch | grep "*" | sed "s/* //").dev.foobar.com
}
branch=$(git branch | grep "*" | sed "s/* //")
open "http://$branch.dev.foobar.com"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM