mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Added readme, updated global functions and pathmunge to work properly
This commit is contained in:
parent
7f825441fc
commit
278616e952
3 changed files with 154 additions and 68 deletions
|
|
@ -1,20 +1,26 @@
|
|||
paths="${DOT_ENV_PATH}/bin
|
||||
/sbin
|
||||
paths=(
|
||||
/bin
|
||||
/usr/X11/bin
|
||||
/sbin
|
||||
/usr/local/bin
|
||||
/usr/local/sbin
|
||||
/usr/bin
|
||||
/usr/sbin
|
||||
/usr/bin"
|
||||
/usr/X11/bin
|
||||
)
|
||||
|
||||
EGREP=`which egrep`
|
||||
function pathmunge () {
|
||||
if ! echo $PATH | $EGREP "(^|:)$1($|:)" > /dev/null ; then
|
||||
if [ -d "$1" ]; then
|
||||
if [ "$2" = "before" ] ; then
|
||||
PATH="$1:$PATH"
|
||||
else
|
||||
PATH="$PATH:$1"
|
||||
fi
|
||||
# If it exists then remove it so we can shuffle it to the end or beginning of the PATH
|
||||
if echo $PATH | $EGREP "(^|:)$1($|:)" > /dev/null ; then
|
||||
safe_param=$(printf "%s\n" "$1" | sed 's/[][\.*^$(){}?+|/]/\\&/g')
|
||||
PATH=`echo $PATH | sed -Ee "s/(^|:)$safe_param($|:)/:/"`
|
||||
fi
|
||||
# add the path in the apropriate location
|
||||
if [ -d "$1" ]; then
|
||||
if [ "$2" = "before" ] ; then
|
||||
PATH="$1:$PATH"
|
||||
else
|
||||
PATH="$PATH:$1"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
@ -26,6 +32,7 @@ done
|
|||
# Prepend path with $HOME/bin
|
||||
pathmunge "$HOME/bin" before
|
||||
|
||||
# Remove : at the beginning and duplicate ::
|
||||
PATH=`echo $PATH | sed -e 's/^\://' -e 's/\:\:/:/g'`
|
||||
unset paths
|
||||
export PATH
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue