From 12b833b974c642a1b201ef5f9762a6894b139ba2 Mon Sep 17 00:00:00 2001 From: Nachuan Tang Date: Sun, 24 Jul 2022 22:09:27 -0400 Subject: [PATCH] modify zsh prompt --- bash_tools/theme_zsh.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/bash_tools/theme_zsh.sh b/bash_tools/theme_zsh.sh index c64dd3e..01f0734 100644 --- a/bash_tools/theme_zsh.sh +++ b/bash_tools/theme_zsh.sh @@ -1,17 +1,30 @@ - # Autoload zsh add-zsh-hook and vcs_info functions (-U autoload w/o substition, -z use zsh style) -autoload -Uz add-zsh-hook vcs_info +#autoload -Uz add-zsh-hook vcs_info # Enable substitution in the prompt. -setopt prompt_subst +#setopt prompt_subst # Run vcs_info just before a prompt is displayed (precmd) -add-zsh-hook precmd vcs_info +#add-zsh-hook precmd vcs_info # Enable checking for (un)staged changes, enabling use of %u and %c -zstyle ':vcs_info:*' check-for-changes true +#zstyle ':vcs_info:*' check-for-changes true # Set custom strings for an unstaged vcs repo changes (*) and staged changes (+) -zstyle ':vcs_info:*' unstagedstr ' *' -zstyle ':vcs_info:*' stagedstr ' +' +#zstyle ':vcs_info:*' unstagedstr ' *' +#zstyle ':vcs_info:*' stagedstr ' +' # Set the format of the Git information for vcs_info -zstyle ':vcs_info:git:*' formats '(%b%u%c)' -zstyle ':vcs_info:git:*' actionformats '(%b|%a%u%c)' +#zstyle ':vcs_info:git:*' formats '(%b%u%c)' +#zstyle ':vcs_info:git:*' actionformats '(%b|%a%u%c)' +#export PS1='%F{green}%1~ %F{cyan}${vcs_info_msg_0_}%f ' + +local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" +local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n@%m%{$reset_color%} " +local user="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n%{$reset_color%} " +local user_symbol='%(!.#.$)' +local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}" + +local vcs_branch='$(git_prompt_info)$(hg_prompt_info)' + +local venv_prompt='$(virtualenv_prompt_info)' + +PROMPT="╭─${user}${current_dir}${vcs_branch}${venv_prompt} +╰─%B${user_symbol}%b " +RPROMPT="%B${return_code}%b" -export PS1='%F{green}%1~ %F{cyan}${vcs_info_msg_0_}%f '