zsh changes

This commit is contained in:
xunuwu 2024-11-10 13:48:18 +01:00
parent 9e955a6386
commit 4d7bdacb0e
Signed by: xun
SSH key fingerprint: SHA256:Uot/1WoAjWAeqLOHA5vYy4phhVydsH7jCPmBjaPZfgI

View file

@ -33,6 +33,8 @@ in {
history = {
expireDuplicatesFirst = true;
extended = true;
save = 100 * 1000;
path = "${config.xdg.dataHome}/zsh_history";
};
initExtra = ''
@ -63,13 +65,31 @@ in {
## PROMPT ##
function preexec() {
timer=$(date +%s%3N)
}
function precmd_timer() {
if [ $timer ]; then
now=$(date +%s%3N)
elapsed=$(($now-$timer))
if [[ elapsed -gt 100 ]]; then
export RPROMPT="%F{cyan}''${elapsed}ms %f"
else
unset RPROMPT
fi
unset timer
fi
}
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
precmd_functions+=( precmd_vcs_info precmd_timer )
zstyle ':vcs_info:git:*' formats ' %b '
setopt prompt_subst
PROMPT="%F{blue}[%F{magenta}%n%F{blue}@%F{magenta}%M%F{blue}] %~%f %F{green}\$vcs_info_msg_0_%f%(?..%F{red}| %? )%#%f "
PROMPT='%F{blue}[%F{magenta}%n%F{blue}@%F{magenta}%M%F{blue}] %~%f %F{green}$vcs_info_msg_0_%f%(?..%F{red}| %? )%#%f '
'';
};
})