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
|
# If not running interactively, don't do anything
|
||||||
[ -z "$PS1" ] && return
|
[ -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 put duplicate lines in the history. See bash(1) for more options
|
||||||
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
|
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
|
||||||
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
|
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
|
||||||
@@ -69,7 +84,9 @@ xterm*|rxvt*)
|
|||||||
esac
|
esac
|
||||||
export PROMPT_DIRTRIM=3
|
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"
|
export IPLAYER_OUTDIR="$HOME/downloads/iplayer"
|
||||||
|
|
||||||
# enable color support of ls and also add handy aliases
|
# enable color support of ls and also add handy aliases
|
||||||
@@ -123,8 +140,6 @@ fi
|
|||||||
# echo "Note - Dropbox isn't running!"
|
# echo "Note - Dropbox isn't running!"
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
export PATH=$HOME/bin:$PATH
|
|
||||||
|
|
||||||
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
||||||
|
|
||||||
# Load any supplementary scripts
|
# Load any supplementary scripts
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ if [ -x /usr/bin/dircolors ]; then
|
|||||||
alias grep='grep --color=auto'
|
alias grep='grep --color=auto'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# export PATH=$HOME/.local/bin:$PATH
|
||||||
|
addpath $HOME/.local/bin
|
||||||
|
|
||||||
# some more ls aliases
|
# some more ls aliases
|
||||||
alias ll='ls -l'
|
alias ll='ls -l'
|
||||||
alias la="ls -a"
|
alias la="ls -a"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Set up NPM
|
# Set up NPM
|
||||||
NPM_PACKAGES="$HOME/.npm-packages"
|
NPM_PACKAGES="$HOME/.npm-packages"
|
||||||
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
|
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
|
||||||
PATH=$PATH:$NPM_PACKAGES/bin
|
|
||||||
MANPATH="$MANPATH:$NPM_PACKAGES/share/man"
|
MANPATH="$MANPATH:$NPM_PACKAGES/share/man"
|
||||||
|
addpath $NPM_PACKAGES/bin
|
||||||
|
|||||||
Reference in New Issue
Block a user