Skip to content

Instantly share code, notes, and snippets.

@swenzel
Created January 11, 2017 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swenzel/237871faabc00dcc24ba4e7858591faf to your computer and use it in GitHub Desktop.
Save swenzel/237871faabc00dcc24ba4e7858591faf to your computer and use it in GitHub Desktop.
Two utility functions for editing and viewing the PATH variable
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