diff options
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/.zsh/prompt.zsh | 98 |
1 files changed, 17 insertions, 81 deletions
diff --git a/zsh/.zsh/prompt.zsh b/zsh/.zsh/prompt.zsh index cf1b525..3e323dd 100644 --- a/zsh/.zsh/prompt.zsh +++ b/zsh/.zsh/prompt.zsh @@ -27,8 +27,8 @@ ICO_BEHIND="↓" #ICO_BEHIND="🠛" #ICO_BEHIND="▼" ICO_DIVERGED="⥮" -COLOR_ROOT="%F{red}" -COLOR_USER="%F{cyan}" +COLOR_ROOT="%{$fg_bold[red]%}" +COLOR_USER="%F{white}" COLOR_NORMAL="%F{white}" PROMPT_STYLE="classic" # Modify the colors and symbols in these variables as desired. @@ -36,7 +36,7 @@ GIT_PROMPT_SYMBOL="%{$fg[blue]%}±" # plus/minus GIT_PROMPT_PREFIX="%{$fg[green]%} %{$reset_color%}" GIT_PROMPT_SUFFIX="%{$fg[green]%}%{$reset_color%}" GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}" # A"NUM" - ahead by "NUM" commits -GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}" # B"NUM" - behind by "NUM" commits +GIT_PROMPT_BEHIND="%{$fg[white]%}BNUM%{$reset_color%}" # B"NUM" - behind by "NUM" commits GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡%{$reset_color%}" # lightning bolt - merge conflict GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" # red circle - untracked files GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}●%{$reset_color%}" # yellow circle - tracked files modified @@ -94,88 +94,24 @@ git_prompt_string() { local git_where="$(parse_git_branch)" # If inside a Git repository, print its branch and state - [ -n "$git_where" ] && echo "$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX" + [ -n "$git_where" ] && echo "[$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX%F{white}]─" # If not inside the Git repo, print exit codes of last command (only if it failed) - [ ! -n "$git_where" ] && echo "%{$fg[red]%}%(?..%?)" + #[ ! -n "$git_where" ] && echo "%{$fg[red]%}%(?..%?)" } -#█▓▒░ git prompt -GIT_PROMPT() { - test=$(git rev-parse --is-inside-work-tree 2> /dev/null) - if [ ! "$test" ] - then - case "$PROMPT_STYLE" in - ascii) - echo "$reset_color%F{cyan}▒░" - ;; - arrows) - echo "$reset_color%F{cyan}" - ;; - esac - return - fi - ref=$(git name-rev --name-only HEAD | sed 's!remotes/!!' 2> /dev/null) - dirty="" && [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && dirty=$ICO_DIRTY - stat=$(git status | sed -n 2p) - case "$stat" in - *ahead*) - stat=$ICO_AHEAD - ;; - *behind*) - stat=$ICO_BEHIND - ;; - *diverged*) - stat=$ICO_DIVERGED - ;; - *) - stat="" - ;; - esac - case "$PROMPT_STYLE" in - ninja) - echo "${COLOR_NORMAL}${ref}${dirty}${stat}" - ;; - ascii) - echo "%{$bg[magenta]%}%F{cyan}▓▒░ %F{black}${ref}${dirty}${stat} $reset_color%F{magenta}▒░" - ;; - arrows) - echo "%{$bg[magenta]%}%F{cyan} %F{black}${ref}${dirty}${stat} $reset_color%F{magenta}" - ;; - *) - echo "${USER_LEVEL}─[${COLOR_NORMAL}"${ref}${dirty}${stat}"${USER_LEVEL}]" - ;; - esac +function error() { + echo "%(?..[$fg[red]%?%F{white}]─)" +} + +function host() { + if [[ -n $SSH_CONNECTION ]]; then + echo "%{$fg_bold[red]%}!$reset_color%F{white}$HOST" + else + echo "$HOST" + fi } -case "$PROMPT_STYLE" in -#█▓▒░ ascii -ascii) -PROMPT='%{$bg[cyan]%} %F{black}%~ $(GIT_PROMPT)$reset_color -%f' -;; -#█▓▒░ arrows -arrows) -PROMPT='%{$bg[cyan]%}%F{black} %~ $(GIT_PROMPT)$reset_color -%f' -;; -#█▓▒░ ninja -ninja) -PROMPT='%F{white} - ▟▙ ${USER_LEVEL}%~ %F{white}$(GIT_PROMPT) %F{white} -▟▒${USER_LEVEL}░░░░░░░%F{white}▜▙▜████████████████████████████████▛ -▜▒${USER_LEVEL}░░░░░░░%F{white}▟▛▟▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▛ - ▜▛ - %f' -;; -#█▓▒░ dual line -dual) -PROMPT='${USER_LEVEL}┌[${COLOR_NORMAL}%~${USER_LEVEL}]$(GIT_PROMPT) -${USER_LEVEL}└─ - %f' -;; -#█▓▒░ classic -*) -PROMPT='%F{cyan}┌─[$USER@$HOST]─[$(git_prompt_string)${USER_LEVEL}]─[${COLOR_NORMAL}%~${USER_LEVEL}] + +PROMPT='%F{white}┌─[${USER_LEVEL}$USER$reset_color%F{white}@$(host)]─$(git_prompt_string)$(error)[%~] └─ - %f' -;; -esac |