bash: use addpath to only add paths once
This commit is contained in:
21
bashrc
21
bashrc
@@ -5,6 +5,21 @@
|
||||
# If not running interactively, don't do anything
|
||||
[ -z "$PS1" ] && return
|
||||
|
||||
# Add an entry to PATH, iff it's not already there.
|
||||
addpath() {
|
||||
wanted_path=$1
|
||||
at_end=$2
|
||||
FOUND=$(echo $PATH | grep $wanted_path)
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Found with grep"
|
||||
if [ "$at_end" == "" ] ; then
|
||||
export PATH=$wanted_path:$PATH
|
||||
else
|
||||
export PATH=$PATH:$wanted_path
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# don't put duplicate lines in the history. See bash(1) for more options
|
||||
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
|
||||
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
|
||||
@@ -69,7 +84,9 @@ xterm*|rxvt*)
|
||||
esac
|
||||
export PROMPT_DIRTRIM=3
|
||||
|
||||
export PATH=$HOME/bin:$PATH:$HOME/opt/bin
|
||||
addpath $HOME/bin
|
||||
addpath $HOME/opt/bin end
|
||||
|
||||
export IPLAYER_OUTDIR="$HOME/downloads/iplayer"
|
||||
|
||||
# enable color support of ls and also add handy aliases
|
||||
@@ -123,8 +140,6 @@ fi
|
||||
# echo "Note - Dropbox isn't running!"
|
||||
# fi
|
||||
|
||||
export PATH=$HOME/bin:$PATH
|
||||
|
||||
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
||||
|
||||
# Load any supplementary scripts
|
||||
|
||||
Reference in New Issue
Block a user