From 1a1b27fa65be19d65d4f758ccc5472486d477cb1 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 25 Jan 2021 18:37:50 +0200 Subject: [PATCH] [zsh] fix the manpath-caused errors on shell startup once and for all --- zsh/path.zsh | 2 +- zsh/zplg.zsh | 2 +- zsh/zshrc | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/zsh/path.zsh b/zsh/path.zsh index 7bf8cac..19c4695 100644 --- a/zsh/path.zsh +++ b/zsh/path.zsh @@ -12,7 +12,7 @@ path_prepend() { fi local var_name="$1"; shift local value; for value in "$@"; do - if eval "(( \${${var_name}[(ie)\$value]} > \${#${var_name}} ))"; then + if eval "(( \${${var_name}[(ie)\$value]-1} > \${#${var_name}} ))"; then eval "${var_name}=(\"\$value\" \"\${${var_name}[@]}\")" fi done diff --git a/zsh/zplg.zsh b/zsh/zplg.zsh index d0a3355..f6a16bf 100644 --- a/zsh/zplg.zsh +++ b/zsh/zplg.zsh @@ -399,7 +399,7 @@ plugin() { else value="${plugin_dir}/${value}" fi - if eval "(( \${${var_name}[(ie)\$value]} > \${#${var_name}} ))"; then + if eval "(( \${${var_name}[(ie)\$value]-1} > \${#${var_name}} ))"; then case "$operator" in prepend) eval "$var_name=(\"\$value\" \${$var_name[@]})" ;; append) eval "$var_name=(\${$var_name[@]} \"\$value\")" ;; diff --git a/zsh/zshrc b/zsh/zshrc index 729b50e..3513103 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -46,15 +46,20 @@ _perf_timer_start "total" fi # }}} +# For some reason manpath is not always set when logging with ssh for instance. +# Let's ensure that it is always set and exported. The additional colon ensures +# that the system manpath isn't overwritten (see manpath(1)), though in reality +# two colons get added for some reason, which is also valid, but means +# something slightly different (again, see manpath(1)). Hope this won't cause +# any problems in the future. +export MANPATH="$MANPATH:" + for script in functions options path env plugins aliases completion zle prompt colorscheme; do _perf_timer_start "$script.zsh" source "$ZSH_DOTFILES/$script.zsh" _perf_timer_stop "$script.zsh" done -# add colon after MANPATH so that it doesn't overwrite system MANPATH -MANPATH="$MANPATH:" - command_exists rbenv && eval "$(rbenv init -)" _perf_timer_stop "total"