File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,16 @@ Colorized:
9090export PS1=" \$ {debian_chroot:+(\$ debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn \]\$ git_branch\[$txtred \]\$ git_dirty\[$txtrst \]\$ "
9191```
9292
93+ #### ZSH
94+
95+ Add this to your ` ~/.zshrc ` :
96+
97+ ``` zsh
98+ source ~ /git-aware-prompt/main.sh
99+ source ~ /git-aware-prompt/colors.sh
100+ export PROMPT=' %{$bldred%}%n@%m%{$txtrst%}:%{$txtgrn%}%~%{$bldpur%}$git_branch%{$txtrst$txtylw%}$git_dirty%{$txtrst%}$ '
101+ ```
102+
93103#### Windows
94104
95105``` bash
Original file line number Diff line number Diff line change @@ -12,8 +12,9 @@ find_git_branch() {
1212}
1313
1414find_git_dirty () {
15- local status=$( git status --porcelain 2> /dev/null)
16- if [[ " $status " != " " ]]; then
15+ # In zsh "status" is a reserved word
16+ local _status=$( git status --porcelain 2> /dev/null)
17+ if [[ " $_status " != " " ]]; then
1718 git_dirty=' *'
1819 else
1920 git_dirty=' '
@@ -22,6 +23,15 @@ find_git_dirty() {
2223
2324PROMPT_COMMAND=" find_git_branch; find_git_dirty; $PROMPT_COMMAND "
2425
26+ # The above works for bash. For zsh we need this:
27+ if [[ -n " $ZSH_NAME " ]]; then
28+ setopt PROMPT_SUBST
29+
30+ autoload add-zsh-hook
31+ add-zsh-hook precmd find_git_branch
32+ add-zsh-hook precmd find_git_dirty
33+ fi
34+
2535# Default Git enabled prompt with dirty state
2636# export PS1="\u@\h \w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
2737
You can’t perform that action at this time.
0 commit comments