1
0
Fork 0

zshrc: some eye candy

This commit is contained in:
Von Random 2021-08-19 20:40:23 +03:00
parent a64b3f20d3
commit 2fe453963f

26
zshrc
View file

@ -70,16 +70,18 @@ bindkey -s '^j' '^atime ^m' # ctrl + j
bindkey '^x^e' edit-command-line bindkey '^x^e' edit-command-line
# }}} # }}}
# {{{ prompt # {{{ prompt
prompt_fmt='%%k%%f[ %s %s:%s %s]\n> ' prompt_fmt='%%k%%f[ %s %s:%s %s]\n\u276f '
prompt_fmtn='%%k%%f[ %%{\e[2;3m%s\e[0m%%} ]\u276f '
prompt_user='%F{%(!.red.blue)}%n%f' prompt_user='%F{%(!.red.blue)}%n%f'
prompt_host='%m' prompt_host='%m'
prompt_cwd='%F{green}%d%f' prompt_cwd='%F{green}%d%f'
prompt_git_fmt='\ue0a0 %s %s%%f ' prompt_git_fmt='\ue0a0 %s %s%%f '
prompt_state_file=${RUN_DIR:-/run/user/$UID}/zsh_gitstatus_$$.tmp prompt_state_file=${RUN_DIR:-/run/user/$UID}/zsh_gitstatus_$$.tmp
PROMPT=$'%k%f[ %n %m:%d ]\n> '
PROMPT2='%k%f[ %_ ] ' printf -v PROMPT $prompt_fmt $prompt_user $prompt_host $prompt_cwd ''
PROMPT3='%k%f[ ?# ] ' printf -v PROMPT2 $prompt_fmtn '%_'
PROMPT4='%k%f[ +%N:%i ] ' printf -v PROMPT3 $prompt_fmtn '?#'
printf -v PROMPT4 $prompt_fmtn '+%N:%i'
precmd.title() { precmd.title() {
case $TERM in case $TERM in
(screen*) printf '\033k%s\033\\' ${HOST%%.*};; (screen*) printf '\033k%s\033\\' ${HOST%%.*};;
@ -87,15 +89,11 @@ precmd.title() {
esac esac
} }
precmd.is_git_repo() { precmd.is_git_repo() {
typeset curr_dir=$PWD read -r git_dir < <(git rev-parse --git-dir 2>/dev/null)
while [[ -n $curr_dir ]]; do if ! ((?)); then
if [[ -r $curr_dir/.git/HEAD ]]; then [[ -e $git_dir/nozsh ]] && return 1
[[ -e $curr_dir/.git/nozsh ]] && return 1 return 0
return 0 fi
else
curr_dir=${curr_dir%/*}
fi
done
return 1 return 1
} }
precmd.git() { precmd.git() {