Search code examples
bashaliasless-unix

Use less -S and less in alias


I always use less -S instead of less, so I create an alias less="less -S".

But sometimes, I want to use less without -S. I tried something like les=less, but of course, it doesn't work because les calls the other alias less -S.

Is there a solution?

(Note: I don't want to just rename my less alias because when other people use my computer they always use less without -S and I find the output hard to read for some huge files.)


Solution

  • Set up the second alias so that it contains the full path to the less executable:

    alias les='/usr/bin/less'
    

    Alternatively, use a backslash to prevent alias expansion:

    alias les='\less'