diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2022-05-10 11:55:09 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2022-05-10 11:55:09 +0200 |
commit | a33579a6671ddfdf4d16b0fa16069634913895ce (patch) | |
tree | fdd6d447cdb6f373ebe56c1df49ccc44f6622e90 /.zsh/utils | |
parent | aeef88301d7a173c0fb6629536c4aaf1652adfa9 (diff) |
zshenv: move path_{append,prepend} to utils
...so these can be used in zshrc as well.
Diffstat (limited to '.zsh/utils')
-rw-r--r-- | .zsh/utils | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -7,6 +7,30 @@ # # Source repository: git://git.distanz.ch/dotfiles/zsh.git +# prepend custom directory to $PATH +path_prepend() +{ + local dir + for dir; do + case "$PATH" in + "*:${dir}:*"|"${dir}:*"|"*:${dir}") :;; + *) test -d "$dir" && path=("$dir" $path);; + esac + done +} + +# append custom directory to $PATH +path_append() +{ + local dir + for dir; do + case "$PATH" in + "*:${dir}:*"|"${dir}:*"|"*:${dir}") :;; + *) test -d "$dir" && path+="$dir";; + esac + done +} + # are we root? is_root() { test ${EUID:?} -eq 0 |