addpath with argument
This commit is contained in:
16
qcd_function
16
qcd_function
@@ -363,7 +363,19 @@ function set_term_title {
|
||||
}
|
||||
|
||||
function path_add_current {
|
||||
# Add current folder to PATH
|
||||
export PATH=$( echo $(pwd):$PATH | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' | sed 's,:\+$,,g' )
|
||||
# Add current or given folder to PATH
|
||||
[[ "$1" = "-h" ]] && {
|
||||
echo 'Add the current folder in PATH, or pass a folder name to be added'
|
||||
return
|
||||
}
|
||||
local p=$(pwd)
|
||||
[[ -z "$1" ]] || {
|
||||
p=$( readlink -e "$1" )
|
||||
}
|
||||
[[ -z "$p" ]] && {
|
||||
echo Path "$1" not found >&2
|
||||
return
|
||||
}
|
||||
export PATH=$( echo ${p}:$PATH | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' | sed 's,:\+$,,g' )
|
||||
echo PATH=$PATH
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user