Wednesday, July 12, 2017

Disabling Some Argument In Shell Command (Linux)

To disable any shell command's argument, all you need to do is to add following code in any of the initialization script of your shell/terminal.
cats_dont_meaow() { 
  if [ $1 = "meaow"]; then
    echo "Cats don\'t meaow in parallel universe."
    cat $*
alias cat=cats_dont_meaow
Thanks to
Consider the application of the script in case you have cached your git credentials and you accidentally hit enter after randomly typing some keys that may become git push origin master. This function will save your gits (pun intended).
block_git_push() {
  if [ $1 = "push" ]; then
    echo "\"push\" is blocked temporarily to prevent volcano eruption."
    git $*
alias git=block_git_push

No comments :

Post a Comment