我很喜欢 oh-my-zsh 并享受 spaceship prompt .
就像它显示我的 git 分支和状态一样 - 我怎样才能让它在旁边显示我当前的 git 用户?
(问的原因是因为我正在做 pair coding 因此它会是有用的信息)
最佳答案
您可以通过为 spaceship-prompt 编写自定义部分来实现此目的。
spaceship_git_user() {
spaceship::is_git || return
local username
username="$(git config user.name)"
if [[ -n $username ]]; then
spaceship::section \
"magenta" \
"$username"
fi
}
然后,将自定义部分添加到飞船提示中。
SPACESHIP_PROMPT_ORDER=(
# content omitted ...
git_user
# content omitted ...
)
在您的提示符(宇宙飞船)初始化之前,将这两部分放入您的.zshrc
。
引用资料
关于git - 如何在终端中显示 git 用户 (oh-my-zsh),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57766085/