Created
January 11, 2017 12:07
-
-
Save swenzel/237871faabc00dcc24ba4e7858591faf to your computer and use it in GitHub Desktop.
Two utility functions for editing and viewing the PATH variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pathed(){ | |
tmpfile=$(mktemp) | |
IFS=':' | |
content='' | |
for p in $PATH; do | |
if [[ -z $content ]]; then | |
content="$p" | |
else | |
content="$content\n$p" | |
fi | |
done | |
echo -e $content > "$tmpfile" | |
"${EDITOR:-vi}" "$tmpfile" | |
export PATH='' | |
while read p; do | |
if [[ -z $PATH ]]; then | |
export PATH=$p; | |
else | |
export PATH=$PATH:$p; | |
fi | |
done < "$tmpfile" | |
rm "$tmpfile" | |
} | |
path(){ | |
IFS=':' | |
for p in $PATH; do | |
echo $p; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment