bash shell显示git分支 function git-branch-name { git symbolic-ref--short-q HEAD2>/dev/null} function git-branch-prompt { local branch=`git-branch-name`if[ $branch ]; then printf"[%s]"$branch; fi } PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-pr...
EN在~/.bashrc文件末尾添加如下代码 function git_branch { branch="`git branch 2>/dev/null |...
可以通过在`~/.gitconfig`文件中添加如下代码: “`bash [alias] br = branch –show-current “` 保存修改后,可以在Git Bash中使用`git br`命令来快速查看当前所在的分支名。 3. 使用`git-prompt`插件来显示分支名:`git-prompt`是Git自带的一个插件,可以用来定制Git Bash的提示符。可以通过在`~/.bashrc`...
– 使用git clone命令克隆 bash-prompt-helpers 仓库: `git clonehttps://github.com/jimeh/git-aware-prompt.git` – 在您的.bashrc文件中添加以下行以加载插件: “` source /path/to/git-aware-prompt/prompt.sh export PS1=”\u@\h \[\033[1;33m\]\w\[\033[0m\]\[$txtcyn\]\$git_branch\[$...
(:70c2952|✔): not on any branch; parent commit has hash 70c2952; the repository is otherwise clean 实现 找到你安装 Git 的地址,在Git/etc目录下将bash-git-prompt项目 clone 下来: git clone https://github.com/magicmonty/bash-git-prompt.git ...
git symbolic-ref --short HEAD2>/dev/null}functiongit-branch-prompt { local branch=`git-branch-name`if[ $branch ];thenprintf"<%s>"$branch;fi} 注:代码详细解释见:https://www.jianshu.com/p/82783f76a868 PS1是 Shell 中的一个特殊变量, 用来表示命令行"提示符", 该变量的可选参数包括: ...
在~/.bashrc文件末尾添加如下代码 function git_branch { branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`" if [ "${branch}" != "" ];then if ...
# Shows Git branch name in prompt. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } # 显示 用户 @ 主机 # export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " # 隐藏用户 @ 主机,显示当前文件夹...
4. The parse_git_branch Function Alternatively, we can use the parse_git_branch function to modify the Bash prompt to show the Git branch with colors. To do this, let’s append the following function to our ~/.bashrc file: # enable colored prompt for git branches # using parse_git_bra...
gitstatus.shandgit-prompt-help.shadded byAKS. Examples The prompt may look like the following: (master↑3|✚1): on branchmaster, ahead of remote by 3 commits, 1 file changed but not staged (status|●2): on branchstatus, 2 files staged ...