1

How can I access the non-aliased version of a command from within the alias for that command? In bash, I can do something like alias ls='\ls -l' to access the non-aliased ls inside this alias for ls. How can I do this in fish?

Right now I'm using env to get the executable for the command, but is there a better way? alias man='PAGER="bat -p" /usr/bin/env man'

1 Answer 1

3

For simple cases, fish's alias will figure it out itself.

You can just do alias ls='ls -l' and it will result in the following function:

 function ls --description 'alias ls=ls -l'
     command ls -l $argv
 end

because

  1. fish's alias is a cheesy wrapper that defines functions
  2. the way to call a command by name, skipping functions and builtins, is to use command

So you can do

alias man='PAGER="bat -p" command man'

(similary, builtin foo calls the builtin "foo", skipping any functions)

In this specific case the best solution is to just set $MANPAGER, skipping the alias entirely:

set -gx MANPAGER "bat -p"

Also, you can avoid any issues with fish's aliases by directly defining a function yourself:

function man
     PAGER="bat -p" command man $argv
end

or using an abbreviation instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .