Search code examples
shellaliaszsh

How do I define a 'no remap' alias?


Here's an example of the kind of alias definition I'm after:

Say I'm an ag user, and I want ag to pay attention to my .ignore file by default. So I add this to my .zshrc:

alias ag='ag --path-to-ignore ~/.ignore'

But I also want a second command, that acts like vanilla ag, for the rare occasions where I do want to search every single file. So I try to do this:

alias agnodotignore='ag'

It doesn't work, all this does is alias agnodotignore to ag --path-to-ignore ~/.ignore.

How can I write a 'no remap' alias definition that ignores my previous alias definition?


Solution

  • the \ is an escape for aliases to get to the actual, un-aliased command.

    alias agnodotignore='\ag'
    

    will give you the default ag output, i.e., not the aliased version

    you could also just type \ag from the command line for the same effect.