diff --git a/qcd_function b/qcd_function index 5c2ec4c..7649f10 100644 --- a/qcd_function +++ b/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 }