Skip to content

Instantly share code, notes, and snippets.

@takuya
Created February 28, 2018 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya/43f4d395ab9513102e19c4689922cec7 to your computer and use it in GitHub Desktop.
Save takuya/43f4d395ab9513102e19c4689922cec7 to your computer and use it in GitHub Desktop.
# alias の代替にfunction を定義
function find(){
local post=()
local pre=()
local opts=()
local path=''
local mindepth=1
while [[ $1 ]]; do
case "$1" in
-H | -L | -P ) pre+=($1);;
-O | -D ) pre+=($1); shift ; pre+=($1);;
-maxdepth ) opts+=($1); shift; opts+=($1) ;;
-mindepth) shift; mindepth=($1);;
* )
if [[ -e $1 ]]; then
path="$1"
else
post+=("$1")
fi
esac
shift
done
# cmd=$(echo $( which find ) ${pre[@]} "$path" -mindepth $mindepth "${opts[@]}" -not -iwholename *.git* )
# echo $cmd "${post[@]}"
# $cmd "${post[@]}"
cmd=$(echo $( which find ) ${pre[@]} "$path" -mindepth $mindepth "${opts[@]}" -not -iwholename "*.git/*" "${post[@]}" )
(>&2 echo $cmd)
$cmd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment