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)
|
||||
|
||||
source ~/.zsh/gitstatus/gitstatus.plugin.zsh
|
||||
|
||||
# Lines configured by zsh-newuser-install
|
||||
HISTFILE=~/.histfile
|
||||
HISTSIZE=1000
|
||||
|
@ -24,21 +26,48 @@ SAVEHIST=1000
|
|||
|
||||
setopt prompt_subst
|
||||
|
||||
get_git_branch() {
|
||||
git symbolic-ref --short HEAD 2> /dev/null
|
||||
}
|
||||
#get_git_branch() {
|
||||
# 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() {
|
||||
local STATUS=$(git status --porcelain 2> /dev/null | tail -1)
|
||||
local BRANCH=$(get_git_branch)
|
||||
if [[ -n $BRANCH ]]; then
|
||||
if [[ -n $STATUS ]]; then
|
||||
echo "%F{cyan}$BRANCH%f %F{yellow}▲%f "
|
||||
git_status=""
|
||||
git_status_v2() {
|
||||
git_status=""
|
||||
if gitstatus_query PROMPT && [[ $VCS_STATUS_RESULT == ok-sync ]]; then
|
||||
local DIRTY=0
|
||||
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
|
||||
echo "%F{cyan}$BRANCH%f %F{green}▲%f "
|
||||
git_status="%F{cyan}$VCS_STATUS_LOCAL_BRANCH%f %F{green}▲%f "
|
||||
fi
|
||||
fi
|
||||
}
|
||||
precmd_functions+=(git_status_v2)
|
||||
gitstatus_stop 'PROMPT' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'PROMPT'
|
||||
|
||||
timer=0
|
||||
timer_show=0
|
||||
|
@ -97,7 +126,7 @@ 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'
|
||||
|
||||
####
|
||||
|
@ -110,6 +139,7 @@ zle -N down-line-or-beginning-search
|
|||
|
||||
bindkey '^?' backward-delete-char # bs delete one char backward
|
||||
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 '^[[F' end-of-line # end go to the end of line
|
||||
bindkey '^[[1~' beginning-of-line # home (2) go to the beginning of line
|
||||
|
|
Loading…
Reference in New Issue