From 419775ef10b85ba8ddf84df6cf300b3d1c5d3057 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Wed, 4 Nov 2015 12:52:29 +0100 Subject: [PATCH] Use easily extensible path manipulation By using a for loop, new entries can easily be added to the PATH without having to enter additional commands. The precedence of the entries can also be easily adjusted by reordering the list that is iterated over. --- bash_profile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bash_profile b/bash_profile index 752ba28..8ccd614 100644 --- a/bash_profile +++ b/bash_profile @@ -22,17 +22,18 @@ export LC_CTYPE="en_US.UTF-8" export LC_ALL="en_US.UTF-8" [ -z "$BACKGROUND" ] && export BACKGROUND="dark" -gnubin=/usr/local/opt/coreutils/libexec/gnubin -[ -d "$gnubin" ] && PATH="$gnubin:$PATH" -[ -d "$HOME/.dotfiles/bin" ] && PATH="$HOME/.dotfiles/bin:$PATH" -[ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH" -export PATH +# Prepend custom bin directories to PATH if they exist. +for p in /usr/local/opt/coreutils/libexec/gnubin "$HOME/.dotfiles/bin" "$HOME/bin" +do + [ -d "$p" ] && export PATH="$p:$PATH" +done -localman=/usr/local/share/man -gnuman=/usr/local/opt/coreutils/libexec/gnuman -[ -d "$localman" ] && MANPATH="$localman:$MANPATH" -[ -d "$gnuman" ] && MANPATH="$gnuman:$MANPATH" -export MANPATH +# Prepend custom man directories to MATPATH if they exist, so that we get +# correct man page entries when multiple versions of a command are available. +for p in localman=/usr/local/share/man /usr/local/opt/coreutils/libexec/gnuman +do + [ -d "$p" ] && export MANPATH="$p:$MANPATH" +done # # Aliases