zshrc: 'better' git prompt, add secondary delete bind for st
This commit is contained in:
parent
b66505f6dc
commit
e7e4f79135
|
@ -1,5 +1,7 @@
|
||||||
fpath=(~/.zsh $fpath)
|
fpath=(~/.zsh $fpath)
|
||||||
|
|
||||||
|
source ~/.zsh/gitstatus/gitstatus.plugin.zsh
|
||||||
|
|
||||||
# Lines configured by zsh-newuser-install
|
# Lines configured by zsh-newuser-install
|
||||||
HISTFILE=~/.histfile
|
HISTFILE=~/.histfile
|
||||||
HISTSIZE=1000
|
HISTSIZE=1000
|
||||||
|
@ -24,21 +26,48 @@ SAVEHIST=1000
|
||||||
|
|
||||||
setopt prompt_subst
|
setopt prompt_subst
|
||||||
|
|
||||||
get_git_branch() {
|
#get_git_branch() {
|
||||||
git symbolic-ref --short HEAD 2> /dev/null
|
# git symbolic-ref --short HEAD 2> /dev/null
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
|
#get_git_dirty() {
|
||||||
|
# git status --porcelain 2> /dev/null
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#git_status=""
|
||||||
|
#get_git_status() {
|
||||||
|
# git_status=""
|
||||||
|
# local BRANCH=$(get_git_branch)
|
||||||
|
# local STATUS=$(get_git_dirty)
|
||||||
|
# if [[ -n $BRANCH ]]; then
|
||||||
|
# if [[ -n $STATUS ]]; then
|
||||||
|
# git_status="%F{cyan}$BRANCH%f %F{yellow}▲%f "
|
||||||
|
# else
|
||||||
|
# git_status="%F{cyan}$BRANCH%f %F{green}▲%f "
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#precmd_functions+=(get_git_status)
|
||||||
|
|
||||||
get_git_status() {
|
git_status=""
|
||||||
local STATUS=$(git status --porcelain 2> /dev/null | tail -1)
|
git_status_v2() {
|
||||||
local BRANCH=$(get_git_branch)
|
git_status=""
|
||||||
if [[ -n $BRANCH ]]; then
|
if gitstatus_query PROMPT && [[ $VCS_STATUS_RESULT == ok-sync ]]; then
|
||||||
if [[ -n $STATUS ]]; then
|
local DIRTY=0
|
||||||
echo "%F{cyan}$BRANCH%f %F{yellow}▲%f "
|
if [[ $VCS_STATUS_NUM_UNSTAGED -gt 0 ]] || [[ $VCS_STATUS_NUM_UNTRACKED -gt 0 ]]; then
|
||||||
|
DIRTY=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $DIRTY -eq 1 ]]; then
|
||||||
|
git_status="%F{cyan}$VCS_STATUS_LOCAL_BRANCH%f %F{yellow}▲%f "
|
||||||
else
|
else
|
||||||
echo "%F{cyan}$BRANCH%f %F{green}▲%f "
|
git_status="%F{cyan}$VCS_STATUS_LOCAL_BRANCH%f %F{green}▲%f "
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
precmd_functions+=(git_status_v2)
|
||||||
|
gitstatus_stop 'PROMPT' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'PROMPT'
|
||||||
|
|
||||||
timer=0
|
timer=0
|
||||||
timer_show=0
|
timer_show=0
|
||||||
|
@ -97,7 +126,7 @@ binary_clock() {
|
||||||
}
|
}
|
||||||
precmd_functions+=(binary_clock)
|
precmd_functions+=(binary_clock)
|
||||||
|
|
||||||
PROMPT=' %(?.%F{magenta}.%F{red})λ%f %1~ $(get_git_status) '
|
PROMPT=' %(?.%F{magenta}.%F{red})λ%f %1~ $git_status '
|
||||||
RPROMPT='%F{yellow}$timer_display%f %(?..%F{red}%?%f )%F{white}$bclock%f'
|
RPROMPT='%F{yellow}$timer_display%f %(?..%F{red}%?%f )%F{white}$bclock%f'
|
||||||
|
|
||||||
####
|
####
|
||||||
|
@ -110,6 +139,7 @@ zle -N down-line-or-beginning-search
|
||||||
|
|
||||||
bindkey '^?' backward-delete-char # bs delete one char backward
|
bindkey '^?' backward-delete-char # bs delete one char backward
|
||||||
bindkey '^[[3~' delete-char # delete delete one char forward
|
bindkey '^[[3~' delete-char # delete delete one char forward
|
||||||
|
bindkey '^[[P' delete-char # delete (2) delete one char forward
|
||||||
bindkey '^[[H' beginning-of-line # home go to the beginning of line
|
bindkey '^[[H' beginning-of-line # home go to the beginning of line
|
||||||
bindkey '^[[F' end-of-line # end go to the end of line
|
bindkey '^[[F' end-of-line # end go to the end of line
|
||||||
bindkey '^[[1~' beginning-of-line # home (2) go to the beginning of line
|
bindkey '^[[1~' beginning-of-line # home (2) go to the beginning of line
|
||||||
|
|
Loading…
Reference in New Issue