irongit

Hygo AI custom shell.

now zsh updates correctly

huncholanehuncholaneauthored
parent 7e9ac48commit 7ab9287c509829c6343e2d371e0443bd24f4873eBrowse files

1 file changed, +20 -2

+20-2setup.sh
@@ -13,10 +13,28 @@ get_git_branch() {
1313 git branch 2>/dev/null | grep '*' | sed 's/* //'
1414 }
1515
16+git_branch_str() {
17+ git_branch=$(get_git_branch)
18+ if [ -n "$git_branch" ]; then
19+ echo "($git_branch)"
20+ fi
21+}
22+
23+update_prompt() {
24+ local git_branch=$(get_git_branch)
25+ if [ -n "$git_branch" ]; then
26+ PROMPT="%F{214}%n@%m %F{white}%~ %F{51}($git_branch)$NEWLINE%F{214}%#%k%f "
27+ else
28+ PROMPT="%F{214}%n@%m %F{white}%~$NEWLINE%F{214}%#%k%f "
29+ fi
30+}
31+
1632 # Set up zsh prompt
1733 if [ -n "$ZSH_VERSION" ]; then
18- NEWLINE=$'\n'
19- PROMPT="%F{214}%n@%m %F{white}%~ %F{51}($(get_git_branch))${NEWLINE}%F{214}%#%k%f "
34+ NEWLINE=$'\n'
35+ autoload -Uz add-zsh-hook
36+ add-zsh-hook precmd update_prompt
37+ update_prompt
2038 fi
2139
2240 # Set up bash prompt