"Xavier Maillard" <x...@maillard.im> writes:

> I am a new fish user trying to figure out all the concepts and features.

Welcome! I'm also a somewhat new fish user, but here's what I use--you can find
my dotfiles at
https://git.sr.ht/~rensoliemans/dotfiles/tree/main/item/fish/dot-config/fish

> Many people seems to mixup abbreviations and functions. I mean, some functi=
> ons could have been abbreviations.

> So, what's the correct way to define an "alias" ?

I would say that there are three ways:

    function ls
        command ls --color=auto $argv
    end

    alias ls="ls --color=auto"

    abbr --add ls ls --color=auto

You can check out these docpages to read more about them:
- https://fishshell.com/docs/current/language.html#syntax-aliases
- https://fishshell.com/docs/current/interactive.html#abbreviations
- https://fishshell.com/docs/current/cmds/alias.html

As for the "correct" way: I don't think there is one. I prefer 'abbr' since I
like that it expands while I type: it's clearer what it does. For some very long
commands I prefer to use 'alias'. I never really use 'function' for this because
you need to remember to start with 'command' and end with '$argv'.

My dotfiles actually use 'alias' often, but I'm starting to love abbreviations
more and more. They can also be very powerful: check out the 'multicd' abbr from
the first link, and the '!!' abbr from the second one. Here's a short asciinema
that shows how they work: https://asciinema.org/a/nSZWuM8RmZ2etbDK5hoinvTjn

-- 
Best,
Rens


_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to