當我在Windows中打開git bash
時,如何打印包含我的git
別名的歡迎消息?在Windows 7的git bash中打印歡迎信息
1
A
回答
4
在交互式登錄到Bash shell(bash --login
)後,終端上會顯示/etc/motd
的內容。如果版本爲Git for Windows你已經省略了文件/etc/motd
,用cat
或你最喜歡的編輯器創建一個。
# == Git Bash on Windows ==
# - /etc/motd = Message of the Day
# - - - - - - - - - - - - -
cat > /etc/motd
Welcome to the Git Bash Shell
- Try "pwd -W" versus "pwd -L"
- - - - - - - - -
CTRL-d
3
只需定義一個HOME
環境變量(未在msysgit中包含的git-bash.bat
腳本中定義)。
在你選擇(例如:%USERPROFILE%
)的目錄,定義一個.bashrc文件,包含以下內容:
git config --get-regexp alias
(從 「How to list/show Git aliases?」)
,將顯示所有每次你用msysgit打開一個bash會話時,git別名。
alias.st status
alias.lg log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relati ve
alias.co checkout
alias.ci commit
alias.br branch
alias.lo !sh -c 'git log $1' -
alias.impact !git ls-files -z | xargs -0n1 git blame -w -C | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/' | sed -r 's/ +$//' | sort -f | uniq -c | sort -nr
然而,OP Wilhelmsen問in the comments:
你知道我怎麼可以省略對打印字別名嗎?
當然,這是一個基本bash String manipulation操作:
a=$(git config --get-regexp alias)
echo "${a//alias./}"
,將顯示:
st status
lg log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relative
co checkout
ci commit
br branch
lo !sh -c 'git log $1' -
impact !git ls-files -z | xargs -0n1 git blame -w -C | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/' | sed -r 's/ +$//' | sort -f | uniq -c | sort -nr
注意${a//alias./}
以取代所有 'alias.
' 從字符串「 a
'由一個空字符串。
並且echo "$..."
的雙引號是強制性的以保持換行符。 (否則,所有別名將顯示在一行行)。
相關問題
- 1. 如何打印歡迎信息,來自Apache的
- 2. Java方法,打印歡迎信息,然後感謝您的信息
- 3. 個性化歡迎信息
- 4. 生成歡迎信息
- 5. git bash在Windows 7
- 6. Ubuntu上的Codeigniter沒有歡迎信息
- 7. 最受歡迎的MySQL rss信息源
- 8. 用htaccess +用php登錄歡迎信息
- 9. Ubuntu如何更改歡迎信息
- 10. 設計確認 - 歡迎信息
- 11. 如何創建歡迎信息
- 12. 如何顯示Pharo 2歡迎信息?
- 13. 應用打開後添加歡迎信息
- 14. 打印信息
- 15. 如何在HTML中編寫PHP用戶名歡迎信息?
- 16. 快速回覆在Messenger Bot歡迎信息中工作嗎?
- 17. 堆信息在Windows 7
- 18. Twilio歡迎致歡迎辭
- 19. php中的用戶歡迎消息
- 20. IIS 7歡迎頁面不顯示
- 21. Windows Phone 7的信息
- 22. 從Windows打印服務器輪詢打印機信息
- 23. 如何在訪問主頁時只顯示歡迎信息?
- 24. 如何在歡迎信息/ MOTD上顯示當前時間?
- 25. Inno Setup - 如何在歡迎頁面上放置信息
- 26. 如何在登錄時顯示歡迎信息通知?
- 27. 如何在歡迎頁面中打開Eclipse中的視圖,因爲它在歡迎頁面下方打開?
- 28. 在ParseException中打印異常的信息
- 29. 在Windows 7中獲取屏幕信息
- 30. Nginx的歡迎信息顯示,而不是WordPress的index.php
哪個命令,你會手動運行,讓你想看到的輸出? –
我不知道,我可能必須手動執行此操作,比如'echo「可用的別名:au:add -u,ct = commit ...' – chwi
哪個_git_命令可以手動運行? –