From 60aea94875524e580de489da133172804add7771 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 12 Oct 2020 10:32:25 +0200 Subject: [PATCH] feat: move zsh prompt to its own file also tweak it a bit -> $ is colored depending on last command exit code -> git infos polished --- .config/zsh/.zshrc | 14 +------------- .config/zsh/zsh_prompt | 13 +++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 .config/zsh/zsh_prompt diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 11aea2c..b8a8023 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -3,7 +3,7 @@ # Enable colors and change prompt: autoload -U colors && colors -PS1="[ %B%{$fg[magenta]%}%(4~|%-1~/.../%2~|%~)%}%{$reset_color%} ] $%b " +source $XDG_CONFIG_HOME/zsh/zsh_prompt # Home/End/Insert/Del keys bindkey '^[[P' delete-char # Delete @@ -12,18 +12,6 @@ bindkey '^[[4~' end-of-line # End bindkey '^[[5~' up-line-or-history # PageUp bindkey '^[[6~' down-line-or-history # PageDown -# Git infos on the right -autoload -Uz vcs_info -precmd_vcs_info() { vcs_info } -precmd_functions+=( precmd_vcs_info ) -setopt prompt_subst -RPROMPT=\$vcs_info_msg_0_ -zstyle ':vcs_info:git:*' check-for-changes true -zstyle ':vcs_info:git:*' stagedstr '*' -zstyle ':vcs_info:git:*' unstagedstr '!' -zstyle ':vcs_info:git:*' formats '%F{214}%r%f %F{208}(%b): %c/%u' -zstyle ':vcs_info:*' enable git - # History in cache directory: HISTSIZE=10000 SAVEHIST=10000 diff --git a/.config/zsh/zsh_prompt b/.config/zsh/zsh_prompt new file mode 100644 index 0000000..c10b5aa --- /dev/null +++ b/.config/zsh/zsh_prompt @@ -0,0 +1,13 @@ +# Git infos on the right +autoload -Uz vcs_info +precmd_vcs_info() { vcs_info } +precmd_functions+=( precmd_vcs_info ) +setopt prompt_subst +zstyle ':vcs_info:git:*' check-for-changes true +zstyle ':vcs_info:git:*' stagedstr '*' +zstyle ':vcs_info:git:*' unstagedstr '!' +zstyle ':vcs_info:git:*' formats '(%F{208}%b%F{015}: %c/%u%F{015}) ' +zstyle ':vcs_info:*' enable git + +PROMPT="[ %B%{$fg[magenta]%}%(4~|%-1~/.../%2~|%~)%}%{$reset_color%} ] \ +\$vcs_info_msg_0_%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})$%{$reset_color%}%b "