From 01472b6d05525d7469fd284dccc9b18f77f833d5 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Sun, 12 Feb 2017 16:09:16 +0100 Subject: [PATCH] Set the custom bin path within a dedicated script The custom bin path was set in multiple places. Each time, the line was identical and supposed the use of a /bin/sh emulation with a common extension. To reduce duplicated code and support other platforms, the custom bin path is now set in a dedicated script that can be source'd. --- .bashrc | 4 +++- .setpath.sh | 4 ++++ .xinitrc | 2 +- .xprofile | 3 +-- .zshrc | 4 +++- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .setpath.sh diff --git a/.bashrc b/.bashrc index 905f2f6..2b46985 100644 --- a/.bashrc +++ b/.bashrc @@ -14,7 +14,9 @@ export PAGER='less' export USER_NICKNAME="Rodolphe Breard" export DEBEMAIL="packages+deb@what.tf" export DEBFULLNAME="$USER_NICKNAME" -[[ ":$PATH:" == *":$HOME/bin:"* ]] || export PATH="$HOME/bin:$PATH" + +# Path +[ -f ~/.setpath.sh ] && . ~/.setpath.sh # Colors [ "$CLICOLOR" -ne 0 ] && hash dircolors 2>/dev/null && eval $(dircolors -b) diff --git a/.setpath.sh b/.setpath.sh new file mode 100644 index 0000000..defa517 --- /dev/null +++ b/.setpath.sh @@ -0,0 +1,4 @@ +BIN_PATH="$HOME/bin" +found=$(echo $PATH | tr ':' '\n' | grep -w "$BIN_PATH") +[ ! "$found" ] && export PATH="$BIN_PATH:$PATH" +true diff --git a/.xinitrc b/.xinitrc index 69b8022..b9eb3b5 100755 --- a/.xinitrc +++ b/.xinitrc @@ -1,7 +1,7 @@ [ -f ~/.xprofile ] && . ~/.xprofile +[ -f ~/.setpath.sh ] && . ~/.setpath.sh DEFAULT_SESSION=qtile -[[ ":$PATH:" == *":$HOME/bin:"* ]] || export PATH="$HOME/bin:$PATH" case "$1" in awesome) diff --git a/.xprofile b/.xprofile index 604562f..c1456e3 100644 --- a/.xprofile +++ b/.xprofile @@ -1,5 +1,6 @@ [ -f /etc/xprofile ] && . /etc/xprofile [ -f ~/.Xresources ] && xrdb -merge ~/.Xresources +[ -f ~/.setpath.sh ] && . ~/.setpath.sh setxkbmap -option compose:menu setxkbmap -option compose:rwin @@ -7,5 +8,3 @@ setxkbmap -option compose:rwin hash xcompmgr 2>/dev/null && xcompmgr & hash xscreensaver 2>/dev/null && xscreensaver -no-splash & hash gpg-agent 2>/dev/null && eval $(gpg-agent --daemon --enable-ssh-support) - -[[ ":$PATH:" == *":$HOME/bin:"* ]] || export PATH="$HOME/bin:$PATH" diff --git a/.zshrc b/.zshrc index 6706102..3a0e56e 100644 --- a/.zshrc +++ b/.zshrc @@ -11,7 +11,9 @@ export PAGER='less' export USER_NICKNAME="Rodolphe Breard" export DEBEMAIL="packages+deb@what.tf" export DEBFULLNAME="$USER_NICKNAME" -[[ ":$PATH:" == *":$HOME/bin:"* ]] || export PATH="$HOME/bin:$PATH" + +# Path +[ -f ~/.setpath.sh ] && . ~/.setpath.sh # Colors [ "$CLICOLOR" -ne 0 ] && hash dircolors 2>/dev/null && eval $(dircolors -b)