Alec Brunelle's Blog

Beautiful Developer Tools: Fish Shell 🐟

July 03, 2019

Photo by Anton Chernyavskiy on Unsplash
local-village

This is part one of my Beautiful Developer Tools series where I focus on apps that I heavily use. They all help me remain calm πŸ§˜β€β™‚οΈ, collected πŸ“š, and productive πŸ› οΈ when writing code.

One of the most underrated features of any tool, in my opinion, is being fully-featured out of the box. No wasted time scouring the web for configurations other users have shared, the best plugins to use, or how to get that one integration working. This is one of the main reasons why I love the Fish shell so much. Right from the start, you have a shell where you can become super productive and not do too much to get your favourite tools working. I’ve been using it every day for three years now so I thought I would share all of the best things about it.

Built-in goodness

Completes your sentences for you

Smart autosuggestions are seldom seen in terminals, let alone built-in. Instead of just beating the competition, the Fish team thought to demolish it. Using the history of your commands, it suggests commands which you can complete with the right-arrow key.

Look ma! No Typing!
example-of-fish-shell-auto-complete

You can also use tab to get all the options. Couple this with npm-scripts-info and you unlock god-like powers.

All npm scripts for this package, with descriptions, IN THE TERMINAL WUT
example-of-fish-shell-tab-complete

This is because Fish knows how to parse CLI tool man pages in many different formats. Git, Docker CLI, package.json, you name it, most commands you try, it will have auto-completions for it.

Never lets you down

My worst memories of bash come from the absence of this feature, syntax highlighting. You can notice it working in the above gif when npm is not complete yet, your current text is red, and turns blue when it’s a valid command.

A simple thing which makes you think, β€œwow, now I am using a shell from the 90’s”!

-r no more

I have always been a fan of familiarity, and wildcards are just that. You can use them in any command filter down the exact files you need with ease.

e.g.

> ls *.jpg

A tiny customization needed to go the extra mile

There aren’t a lot of extra packages needed for Fish. Personally, I only use 2, which is wild because at one point I know my Oh-My-Zsh plugins were past 10.

Oh My Fish

A homage to the great Oh My Zsh, omf is the most popular package manager for Fish. I use this to install just two packages, one for nvm and one for spacefish.

SpaceFish

Special mention to Spacefish for being the best shell prompt I have ever used. Support for showing:

  • Current Git branch and rich repo status
  • Current Node.js version, through nvm
  • Package version, if there is a package in the current directory (package.json for example)
Spacefish example
spacefish-shell-prompt-example

Caveats

Not being POSIX compliant can scare some developers away. But really in my three years of usage (mostly Node.js, javascript, ruby, e.t.c.), I have not encountered any issues. Some commands I get from the internet which are Bash specific, I’ll just exit and then come back to Fish when I finish. This Stackoverflow post goes into it more if you are so inclined.

Resources:


Alec Brunelle

Written by Alec Brunelle who lives and works in Toronto, building useful things. Email Me, follow me on Dev.to, tip me using Brave, or support me on Ko-fi