亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將bash腳本直接嵌入git別名中

如何將bash腳本直接嵌入git別名中

慕俠2389804 2019-11-27 10:32:52
我可以嵌入以下bash shell代碼:for name in $(git diff --name-only $1); do git difftool $1 $name & done直接進入創建git別名:git config --global alias.diffall ***my-bash-code-here***這是從我之前關于SO的問題/答案開始的,在該問題中,我將代碼放入.sh文件中,然后將其別名為該文件:git config --global alias.diffall '!sh diffall.sh'但是,在對簡單性的永無止境的追求中,是否有一種方法可以跳過文件并將代碼直接插入別名中?我不知道格式...
查看完整描述

3 回答

?
湖上湖

TA貢獻2003條經驗 獲得超2個贊

我在文檔中找不到,但是如果您在路徑中創建腳本“ git- <名稱>”,則可以在存儲庫中使用“ git name”來調用它。


看到:


$ cd ~/bin

$ echo "echo I love this log:

>pwd

>git log --graph  --summary --decorate --all" > git-logg

$ chmod +x git-logg

$ cd /path/to/your/repo

$ git logg

I love this log:

/path/to/your/repo

* commit 3c94be44e4119228cc681fc7e11e553c4e77ad04 (whatever-branch)

| Author: myself <my@Laptop.(none)>

| Date:   Fri Apr 1 16:47:20 2011 +0200

|     would have been better not to do it at all

...

$

因此,您也可以使用這種(不太明顯的)方式來編寫自己喜歡的任何別名。


您甚至可以在該函數的新命令中添加自動補全功能。這里的信息


$ _git_logg ()

{

  # you can return anything here for the autocompletion for example all the branches

  __gitcomp_nl "$(__gi


查看完整回答
反對 回復 2019-11-27
  • 3 回答
  • 0 關注
  • 721 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號