From 91c4fe431cfc1c240b9ecc37e8e6b05854e7d64e Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Tue, 16 Feb 2016 19:20:07 +0000 Subject: [PATCH] Use a new method for prepending to the PATH variable. --- .bashrc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index a979775..ac4085a 100644 --- a/.bashrc +++ b/.bashrc @@ -1,3 +1,9 @@ +pathadd() { + if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then + PATH="$1${PATH:+":$PATH"}" + fi +} + #-------------------------------------------------------------------------------- # The best editor #-------------------------------------------------------------------------------- @@ -20,7 +26,9 @@ mkdir -p ~/src ~/tmp ~/var/log #-------------------------------------------------------------------------------- # Update the path with local overrides #-------------------------------------------------------------------------------- -export PATH=~/bin:/usr/local/bin:/usr/local/sbin:${PATH} +pathadd /usr/local/sbin +pathadd /usr/local/bin +pathadd ~/bin #-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------