Last active
December 17, 2015 08:08
-
-
Save azet/5577607 to your computer and use it in GitHub Desktop.
dynamic aliasing in bash
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
# 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