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
|
||||
|
||||
@@ -3,6 +3,9 @@ if [ -x /usr/bin/dircolors ]; then
|
||||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
# export PATH=$HOME/.local/bin:$PATH
|
||||
addpath $HOME/.local/bin
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -l'
|
||||
alias la="ls -a"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Set up NPM
|
||||
NPM_PACKAGES="$HOME/.npm-packages"
|
||||
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
|
||||
PATH=$PATH:$NPM_PACKAGES/bin
|
||||
MANPATH="$MANPATH:$NPM_PACKAGES/share/man"
|
||||
addpath $NPM_PACKAGES/bin
|
||||
|
||||
Reference in New Issue
Block a user