From b7fa9465c6e7fb3500bad7a7c4139ec7617a145c Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 17 Oct 2022 12:31:49 -0400 Subject: [PATCH] zsh: zsh: i have further fucked it --- zsh/.config/zsh/config.d/00_create_arrays.zsh | 3 +++ zsh/.config/zsh/config.d/30_prompt.zsh | 1 - zsh/.config/zsh/config.d/30_rprompt.zsh | 11 ++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 zsh/.config/zsh/config.d/00_create_arrays.zsh diff --git a/zsh/.config/zsh/config.d/00_create_arrays.zsh b/zsh/.config/zsh/config.d/00_create_arrays.zsh new file mode 100644 index 0000000..efe9a24 --- /dev/null +++ b/zsh/.config/zsh/config.d/00_create_arrays.zsh @@ -0,0 +1,3 @@ +# creates the preexec_functions and precmd_functions arrays to be filled later +export preexec_functions=() +export precmd_functions=() diff --git a/zsh/.config/zsh/config.d/30_prompt.zsh b/zsh/.config/zsh/config.d/30_prompt.zsh index fb7147a..57a43b5 100644 --- a/zsh/.config/zsh/config.d/30_prompt.zsh +++ b/zsh/.config/zsh/config.d/30_prompt.zsh @@ -10,4 +10,3 @@ precmd_functions+="vcs_info" # Prompt shows hostname if connected to a remote or if root PROMPT="%B$([ -n "$is_remote" ] || [ "$EUID" = 0 ] && echo "%F{magenta}%m%f ")%F{$([ "$EUID" = 0 ] && echo "red" || echo "cyan")}%n%f %F{blue}%~%f%b \${vcs_info_msg_0_}%B%#%b " - diff --git a/zsh/.config/zsh/config.d/30_rprompt.zsh b/zsh/.config/zsh/config.d/30_rprompt.zsh index 66cf3e8..d091afe 100644 --- a/zsh/.config/zsh/config.d/30_rprompt.zsh +++ b/zsh/.config/zsh/config.d/30_rprompt.zsh @@ -1,14 +1,15 @@ # Hook preexec/precmd to dynamically set rprompt with useful info +preexec_functions+=start_prompt_timer function start_prompt_timer { # Store command execution start time timer="${timer:-"$(date +%s.%N)"}" } -preexec_functions+="start_prompt_timer" -# this actually does need to be the precmd function because it needs to run -# before any other precmd hooks (e.g. the VS Code terminal integration hook) -# happen, otherwise $? will be fucked -function precmd { +# this needs to be the first precmd function because it needs to run before any +# other precmd hooks (e.g. the VS Code terminal integration hook) happen, +# otherwise $? will be fucked +precmd_functions=(build_rprompt ${precmd_functions[@]}) +function build_rprompt { # Start with a fresh prompt RPROMPT="" if [ -z $new_session ]; then