diff --git a/qcd_function b/qcd_function index 6731f5b..ab3ded8 100644 --- a/qcd_function +++ b/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 }