Last active
April 6, 2019 06:49
-
-
Save michaelpass/c6906f3651c94bb879c1af4f6aee92c7 to your computer and use it in GitHub Desktop.
Revisions
-
michaelpass revised this gist
Jan 17, 2019 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,14 @@ # _ / /\__ \ | | | | | (__ # (_)___|___/_| |_|_| \___| # Deduplicate path variables get_var () { eval 'printf "%s\n" "${'"$1"'}"' } set_var () { eval "$1=\"\$2\"" } dedup_pathvar () { pathvar_name="$1" pathvar_value="$(get_var "$pathvar_name")" -
michaelpass created this gist
Jan 17, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # _ # _______| |__ _ __ ___ # |_ / __| '_ \| '__/ __| # _ / /\__ \ | | | | | (__ # (_)___|___/_| |_|_| \___| dedup_pathvar () { pathvar_name="$1" pathvar_value="$(get_var "$pathvar_name")" deduped_path="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$pathvar_value")" set_var "$pathvar_name" "$deduped_path" } dedup_pathvar PATH dedup_pathvar MANPATH dedup_pathvar PYTHONPATH