mishchief
mishchief

Reputation: 541

How can I block a command from running in my terminal using zsh?

I basically want to stop my computer from running this command on my terminal:

git checkout master

My first thought was adding an alias, but the alias will not grab the whole command just the first part.

Basically if I run the command I want to echo a message, nothing too fancy.

So I was wondering what was the best way of doing this?

Upvotes: 0

Views: 218

Answers (1)

Gairfowl
Gairfowl

Reputation: 2980

The shadow function for git that @chepner suggested looks to be simple enough if you only need to handle a small set of parameters:

git(){
  if [[ "$1 $2" == "checkout master" ]]; then
    print "never mind"
    return 1
  fi
  =git "$@"
}

Upvotes: 2

Related Questions