Skip to content

Instantly share code, notes, and snippets.

@crabdancing
Created September 22, 2021 19:41
Show Gist options
  • Save crabdancing/804bba39da7b810aa82a4b065fe5cb67 to your computer and use it in GitHub Desktop.
Save crabdancing/804bba39da7b810aa82a4b065fe5cb67 to your computer and use it in GitHub Desktop.
# TODO: replace with mechanism that rearranges existing
while read line; do
case "$line" in
''|\#*) continue ;; # skip blanks
esac # Stolen from: https://unix.stackexchange.com/questions/244465/how-to-make-bash-built-in-read-ignore-commented-or-empty-lines
# Expand tilda
line=${line/#\~/$HOME}
# If exists (as directory)
if [ -d "$line" ]; then
# If isn't in PATH
if [[ :$PATH: != *:"$line":* ]]; then
# Add to PATH and export
export PATH="$PATH:$line"
fi
fi
done < /etc/paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment