Last active
February 26, 2020 10:29
-
-
Save benkrikler/69df94f360629afa4cd5c36cbc46fc5e to your computer and use it in GitHub Desktop.
Bash function to open a given "PATH" variable (PATH, LD_LIBRARY_PATH, PYTHONPATH, etc) in an editor with each field on one line, then reassemble the path with colon separators
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
edit_path () | |
{ | |
local tmpfile=$(mktemp); | |
local variable="${1:-PATH}"; | |
tr ':' '\n' <<< "${!variable}" > "$tmpfile"; | |
"$EDITOR" "$tmpfile"; | |
export ${variable}="$(tr '\n' : < "$tmpfile"| sed -e 's/:$//' )" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment