Functions for fish

Fantastic fabulous fish

2 min read    30 Aug 2017    

For fish, foremost forewords fixing familiarity:
Furious fat fabulous fantastic
Flurries of funk felt feeding the fanatics
Functions facing frontal fuzzy-oligies.
Universal, unique untouched
Unadulterated, unambiguously uncut.

Sorry for the flickering failure. Just some Blackalicious lyrics stuck in my head.

Fish stands for friendly interactive shell. I’ve been using fish shell since Feb ‘17, and I’m loving it. I’ll be describing my experience with fish so far, and some fish functions I find useful, either written by me or otherwise.

If you’ve already been using fish, you can skip to Functions.

Features

Light AF

Installing takes < 5 minutes. Hackercodex has an excellent installation guide.

You need a plugin manager like fisherman or oh-my-fish to explore all the more fantastic stuff fish has to offer.

Life is colourful, so must be your fish shell. Have a look at omf’s available awesome themes. An awesome fish compilation.

Fast AF

I had the displeasure of a failing hard disk. The situation was so bad running a command in shell took 10 seconds to begin with. This was also the time I discovered zsh, so I gave it a try.

The installation took over 40 minutes and the situation worsened. A friend recommended fish, which made the old shell look like a snail. So when I got a new disk, fish was one of the first packages I installed. As they say, “Once you go fish, you won’t like anything else on the dish.”

Autocomplete and Coloured commands

The gif should explain it.

Circle through programs / commands / previously run commands by up/down arrows, autocomplete with right arrow.

As you might notice, incorrect commands are coloured red, correct commands are coloured white, and args are blue. (That might be my colour scheme specific)

Easy config

Just run fish_config and a web interface will help you find the configuration you want.

Fair warning: Some of the bash utilites are lost, ‘   ’, ‘&&’, and ‘!’ are replaced with ‘and’, ‘or’, and ‘not’. However, it has a great error reporting system, which suggests corrective measures for these kinds of differences.

Functions

Show me the codes, amirite?

Using functions, you can list down all functions in fish (available at ~/.config/fish/functions/). You can view the code for a function using function functionname. What are functions and why should you use them?

For anyone aware of aliases, functions are just another way of expressing aliases. Writing functions takes advantage of fish’s lazy-loading / autoloading mechanism.

  • clearcache - clear pagecache, dentries and inodes
  • delete_branch - clear pagecache, dentries and inodes
  • fuggit - Remove pack files, and reduce the size of the repo
  • level - Percolate through certain level of directories, with file size.
  • list - list all dirs in folder with sizes
  • squash - squash previous num commits in current folder
  • whatis - Print the description of a Fish function.

The code for them is available in my dotfiles.

Source1 Reference

Some rights reserved.

Leave a Comment