1
0
mirror of https://github.com/bertptrs/vimconfig.git synced 2025-12-25 20:40:32 +01:00

Rework prompt to have VCS information.

This commit is contained in:
2019-04-11 16:15:18 +02:00
parent 4b72b16e49
commit 8496baaa7f
2 changed files with 30 additions and 16 deletions

View File

@@ -194,19 +194,3 @@ SAVEHIST=$HISTSIZE
setopt autocd # Automatically cd to dirs typed
setopt notify
############################
# Configure terminal title #
############################
precmd ()
{
print -Pn "\e]0;%n@%m: %2~\a"
}
preexec ()
{
if [ -n $1 ]; then
cmd=${1:0:20}
print -Pn "\e]0;$1\a"
fi
}

View File

@@ -3,6 +3,21 @@
# Allow color escape sequences to be available
autoload -U colors && colors
# Initialize VCS prompt configuration
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' check-for-staged-changes true
zstyle ':vcs_info:*' actionformats \
'%F{5}(%f%s@%r%F{5})%F{3} - %F{5}[%F{2}%u%b%c%F{3}|%F{1}%a%F{5}]%f'
zstyle ':vcs_info:*' formats \
'%F{5}(%f%s@%r%F{5})%F{3} - %F{5}[%F{2}%u%b%c%F{5}]%f'
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' unstagedstr '~'
zstyle ':vcs_info:*' stagedstr '±'
# Allow calling functions inside prompt
setopt PROMPT_SUBST
@@ -42,6 +57,7 @@ function prompt_ps1() {
"$dir"
$'\n'
'$(prompt_handle_virtualenv)'
'${vcs_info_msg_0_:+${vcs_info_msg_0_}\n}'
"$prompt"
)
echo "${(j::)ps1}"
@@ -58,6 +74,20 @@ function prompt_rprompt() {
echo "${(j::)rprompt}"
}
function precmd () {
# Set window title to username@machine: pwd
print -Pn "\e]0;%n@%m: %2~\a"
# Load VCS info
vcs_info
}
function preexec () {
# Set window title to command about to be executed.
if [[ -n $1 ]]; then
print -Pn "\e]0;$1\a"
fi
}
PS1="$(prompt_ps1)"
RPROMPT="$(prompt_rprompt)"