qcd more BSD compliant
This commit is contained in:
13
qcd_function
13
qcd_function
@@ -1,10 +1,17 @@
|
||||
|
||||
## improved CD commands:
|
||||
_QCD_FIND=find
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias tac=gtac
|
||||
_QCD_FIND=gfind
|
||||
;;
|
||||
esac
|
||||
|
||||
function gcd() {
|
||||
# guess cd, find first match in folder, or ask if multiple hits
|
||||
local cdto QCDPATH
|
||||
QCDPATH=$( dirname ${BASH_SOURCE[0]} )
|
||||
QCDPATH=$( dirname $( realpath ${BASH_SOURCE[0]} ) )
|
||||
cdto=$( python "$QCDPATH"/files/gcd-findmatch.py "$@" )
|
||||
[[ -z "$cdto" ]] && return
|
||||
\cd "$cdto"
|
||||
@@ -221,7 +228,7 @@ function scd() {
|
||||
} || {
|
||||
cdfrom="$2"
|
||||
}
|
||||
cdto=$( find "$cdfrom" -mindepth 1 -type d -iname "*$1*" | sort -V | head -n 1 )
|
||||
cdto=$( $_QCD_FIND "$cdfrom" -mindepth 1 -type d -iname "*$1*" | sort -V | head -n 1 )
|
||||
echo $cdto
|
||||
[[ -z "$cdto" ]] && return
|
||||
\cd "$cdto"
|
||||
@@ -297,7 +304,7 @@ function rmv () {
|
||||
# remove empty folders from sources (not last argument)
|
||||
for (( i=1; i<=$(($#-1)); i++ ))
|
||||
do if [ -d "${!i}" ]
|
||||
then find "${!i}" -depth -type d -exec rmdir \{\} \;
|
||||
then $_QCD_FIND "${!i}" -depth -type d -exec rmdir \{\} \;
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user