dotfiles/bin/consolidate-path

13 lines
233 B
Bash
Executable file

#!/bin/bash
# Usage: PATH="$(consolidate-path "$PATH")"
#
# Remove duplicate entries from PATH.
result=":"
IFS=:
for p in $1; do
[[ "$result" == *:"$p":* ]] || result="${result}${p}:"
done
result="${result#:}"
echo "${result%:}"