我常常會在項目根目錄中右鍵點開 Git Bash 進行一些命令行操做,默認窗口中會顯示當前文件目錄和 git 分支名,但我但願能看到更多信息,如是否存在未提交的修改、未推送的提交等,這樣我在天天打開 bash 窗口後就能對當前項目的狀態有個大概的瞭解。git
我在網上查閱了一番,最終決定使用 bash-git-prompt。github
先放上最終的效果對比圖:
默認窗口
安裝 bash-git-prompt
後shell
相關含義以下(詳情查看 bash-git-prompt 官方說明):windows
(master↑3|✚1): on branch master, ahead of remote by 3 commits, 1 file changed but not staged (status|●2): on branch status, 2 files staged (master|✚7…): on branch master, 7 files changed, some files untracked (master|✖2✚3): on branch master, 2 conflicts, 3 files changed (master|⚑2): on branch master, 2 stash entries (experimental↓2↑3|✔): on branch experimental; your branch has diverged by 3 commits, remote by 2 commits; the repository is otherwise clean (:70c2952|✔): not on any branch; parent commit has hash 70c2952; the repository is otherwise clean
找到你安裝 Git 的地址,在 Git/etc
目錄下將 bash-git-prompt 項目 clone 下來:bash
git clone https://github.com/magicmonty/bash-git-prompt.git
而後用編輯器打開 Git/etc
目錄下的 bash.bashrc
文件,註釋其中所有代碼,新增以下三行代碼:編輯器
GIT_PROMPT_ONLY_IN_REPO=1 GIT_PROMPT_THEME=Evermeet # 主題能夠本身選,在 Git\etc\.bash-git-prompt\themes 中挑一個 source /etc/.bash-git-prompt/gitprompt.sh
保存文件後,從新打開 Git Bash 窗口,Voila!安裝好了~spa
若是你發現窗口中的打勾和箭頭等符號顯示有問題,能夠這樣作:右鍵窗口標題欄 -> Options -> Text -> Font Select -> DejaVu Sans Mono
命令行
參考:Strange charactercode
The font limitation shows up in the default Ubuntu shell on Windows 10 as well but I was able to see the glyph characters by simply using DejaVu Mono https://dejavu-fonts.github.io/.
What @scotlynhatt means is download the font on windows, install it and then select it from the font menu for the WSL window (right click on the title bar -> properties -> font).