Better shell with Fish and One theme
If you’re a developer, you most likely had to work with shell at some point. If you’re a web developer, you’re most likely spending quite a lot of time in your terminal. I certainly do, and for some time I’ve been looking for ways to make my work with terminal a bit more productive. And this search brought me to Fish and a framework for it — “Oh My Fish”. Here’s a little guide on what it is and how to use it.
What is Fish?
Fish is a custom shell, much like Zsh but a little better. If you didn’t customize your shell before you’re most likely using bash as your default shell.
Fish provides a ton of useful features like autocomplete, rich coloring, custom scripting and more. But the real deal is Oh My Fish framework (much like “Oh My Zsh” for Zsh) that allows easy installation of custom themes and plugins for your shell.
How to get it?
If you’re on a Mac and you have Homebrew installed, you can simply run:
brew install fish
And Fish will be installed. There are other download options available at https://fishshell.com.
After you have installed Fish and set it as your default shell it’s time to install Oh My Fish. To do this, simply run:
curl -L http://get.oh-my.fish | fish
If you’re a Node.js developer and are using NVM I strongly recommend installing NVM plugin. To do it just run:
omf install nvm
After this NVM command will be available in Fish as usual.
Okay, this is all good, but you mentioned some kind of theme?
Yes! Like I said, the true beauty of Fish shines in custom themes. There are a few good ones available in the default listing (accessible via
omf theme command or via link I mentioned above). But none of those themes felt right to me, so I created my own. It’s based on the Toaster theme and adds a bunch of useful features like:
- Removes the god-awful huge emoji
- Replaces enormous Git indicators with nicer ones
- Shows if local Git is ahead/behind of origin (↑ and ↓ with # of commits)
- Shows local repository status indicators (explained below)
- Shows current branch
- Abbreviates current working directory
- Shows currently used Node.js version
- Displays current time
- Displays red [!] if previous command failed
- Indicates superuser privileges [⚡️]
The theme is called “One” because it reminds me of Atom’s “One Dark” theme. To install it, simply run:
omf install one
You might run into some issues on macOS after installing. If you get an
expr: syntax error message, try expr from coreutils package. If you get an
Array index out of bounds error, simply run
brew install --with-default-names gnu-sed.
Okay, but what’s with the Git stuff?
Here’s the cheat sheet of what each color circle means about local Git repository:
This might look a little confusing at first but after you make a few commits and see it in action you’ll be able to get around with ease.
Fish together with this theme allows me to see everything I need to see right in my terminal and autocomplete saves a lot of typing. I’m talking about like a lot.
And since Fish works perfectly fine with Atom’s Terminal Plus package I don’t have to leave the editor or execute any additional commands to know what Node version I currently have selected, what branch I’m on and so on.
Among possible to-dos maybe make some features optional and add configuration options, but so far I’m pretty happy with the end result.
The source code is available on GitHub.