24 lines
534 B
Bash
24 lines
534 B
Bash
#!/bin/zsh
|
|
# shellcheck disable=SC2206
|
|
# shellcheck disable=SC2179
|
|
# shellcheck disable=SC2154
|
|
|
|
# In case a plugin adds a redundant path entry, remove duplicate entries
|
|
# from PATH
|
|
#
|
|
# This snippet is from Mislav Marohnić <mislav.marohnic@gmail.com>'s
|
|
# dotfiles repo at https://github.com/mislav/dotfiles
|
|
dedupe_path() {
|
|
typeset -a paths result
|
|
paths=($path)
|
|
|
|
while [[ ${#paths} -gt 0 ]]; do
|
|
p="${paths[1]}"
|
|
shift paths
|
|
[[ -z ${paths[(r)$p]} ]] && result+="$p"
|
|
done
|
|
|
|
export PATH=${(j+:+)result}
|
|
}
|
|
|
|
dedupe_path
|