Skip to content

Instantly share code, notes, and snippets.

@azet
Last active December 17, 2015 08:08
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 azet/5577607 to your computer and use it in GitHub Desktop.
Save azet/5577607 to your computer and use it in GitHub Desktop.
dynamic aliasing in bash
# here be dragons
syscommon_eval_bin() {
# figure out pwd
# search params for lustre path
chklfs() {
if [[ $PWD == *lustre* ]] || [[ "$*" == *lustre* ]]; then
return 0
else
return 1
fi
}
# check for executed binary
case "$1" in
du|find)
local cmd
cmd=$1
shift
if chklfs $@; then
rbh-${cmd} $*
else
command ${cmd} $@
fi
;;
*)
return 1
;;
esac
}
# e.g.
alias du='syscommon_eval_bin du $@'
alias find='syscommon_eval_bin find $@'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment