Created
October 10, 2012 11:00
-
-
Save markusfisch/3864786 to your computer and use it in GitHub Desktop.
Make BSD/OSX find/cp/mv behave like the GNU/Linux tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simply put that into your ~/.profile or ~/.bash_aliases | |
# Auto-complete BSD/OSX find to behave like GNU find | |
# | |
# @param ... - find params | |
find --version &>/dev/null || find() | |
{ | |
local P= | |
[ -d "$1" ] || P=. | |
command find $P "$@" | |
} | |
# Make BSD/OSX cp/mv behave like GNU cp/mv i.e. fix that counter-intuitive | |
# behaviour of copying/moving files instead of directories when given with | |
# a closing slash | |
# | |
# @param ... - argument to cp | |
cp --version &>/dev/null || { | |
fix_cp_mv() | |
{ | |
local C | |
for C in cp mv | |
do | |
eval "$C() | |
{ | |
local A ARGS=() | |
for A in \"\$@\" | |
do | |
[ -d \"\$A\" ] && A=\${A%/} | |
ARGS=( \"\${ARGS[@]}\" \"\$A\" ) | |
done | |
command $C \"\${ARGS[@]}\" | |
}" | |
done | |
} | |
fix_cp_mv | |
unset fix_cp_mv | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this error:
I'm on OS X Mountain Lion.