安裝:
- curl install 執(zhí)行:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
- wget install 執(zhí)行:
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
安裝后重啟終端即可:
image.png
如果需自定義:例如顯示當(dāng)前目錄的絕對(duì)路徑,分支變更信息等。
cd $ZSH/themes
進(jìn)入robbyrussell.zsh-theme文件,將文件替換成以下內(nèi)容
vi robbyrussell.zsh-theme
PROMPT+='%{$fg[cyan]%}%~$reset_color%} $(git_time_since_commit) $(git_super_status)'
RPROMPT=""
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
function git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
if git log -n 1 > /dev/null 2>&1; then
# Get the last commit.
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
now=`date +%s`
seconds_since_last_commit=$((now-last_commit))
# Totals
MINUTES=$((seconds_since_last_commit / 60))
HOURS=$((seconds_since_last_commit/3600))
# Sub-hours and sub-minutes
DAYS=$((seconds_since_last_commit / 86400))
SUB_HOURS=$((HOURS % 24))
SUB_MINUTES=$((MINUTES % 60))
if [[ -n $(git status -s 2> /dev/null) ]]; then
if [ "$MINUTES" -gt 30 ]; then
COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
elif [ "$MINUTES" -gt 10 ]; then
COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
else
COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
fi
else
COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
fi
if [ "$HOURS" -gt 24 ]; then
echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
elif [ "$MINUTES" -gt 60 ]; then
echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
else
echo "($COLOR${MINUTES}m%{$reset_color%}|"
fi
else
COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
echo "($COLOR~|"
fi
fi
}
更新完后,修改~/.zshrc文件下的 plugins =(git)
改為:plugins=(git vscode npm npx kubectl history git-flow git-prompt)
關(guān)掉后重新打開(kāi)搞定!
image.png
??注意:如tab的快捷命令不好使,請(qǐng)下載 zsh.diff
鏈接: https://pan.baidu.com/s/1wF2NP7o9LBOPsDaUCzHdWQ 提取碼: j98g
執(zhí)行命令
cd $ZSH
git diff
git co .
git apply ~/Downloads/zsh.diff #git apply zsh.diff目錄名稱(chēng) 我的在~/Downloads/目錄下