Search code examples
linuxshellterminalaliasfish

Defining an Alias to Image Magick in Fish Shell


I would like to use Image Magick to trim some images via

convert -trim image.png image.png

Is there a way to register an alias in Fish Shell, that would shorten the above statement to something like this?

trim image.png

If so, how do I implement this?


Solution

  • fish does not have aliases; you need to define a function instead.

    function trim
        convert -trim $argv[1] $argv[1]
    end
    

    Running fish -c help (or simply help if you are already in a fish session) will open the fish documentation in a web browser, where you can find the documentation for the function command used to define shell functions.