Technology Inside Out!

Index ¦ Archives ¦ Atom ¦ RSS

Get rid of your old terminal, Go Fish-ing

Tired of using Bash terminal? Struggling with shell scripting. Want to try something better, easier to customize, configure. Fish is a simple, powerful yet user-friendly command-line shell giving you features that you have never heard of such as auto-suggestions, cleaner more organized scripts, web-based configuration/ customizations and a lot more. Read on for my take on Fish and how it can make you more productive in your day-to-day.

Simple Installation

Fish is easily available on Linux (All popular distros), Windows, and MacOS. Here are the steps for installing it on Debian.

sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install fish

You can find similar installation steps, for other distros and operating systems here. When fish gets installed, type the following in your terminal.

- $ fish

And you are ready to go.

For Fish to remember and suggest properly, try running this command when you install new applications. This will start scanning the man pages of your distros and suggest new arguments as you type in the terminal. To accept a suggestion, press the right arrow key to complete the command and it as simple as that.

- $ fish_update_completions

Let's Play

The official website of Fish offers an easy tutorial for both beginners and professionals to get started and make the most of it. I'll be mentioning the features I use the most and love while using Fish.

Summons commands like a pro

Fish provides suggestions and completions to every command and their specific arguments that you would type in the shell, from the get-go. Start typing to see it for yourself.
This works on its ability to predict arguments straight from man pages and from the history it maintains, of the previous commands you entered. (Don't worry its smart enough not to record any sensitive information)

No need to remember arcane syntax, arguments or commands. Since it remembers what you type, it will keep suggesting you more recent commands to increase productivity and let you focus more on what you are going to type next.

Similarity to old 'Bash' (and some new scripting rules)

Commands you use in bash or to write shell scripts in Bash are mostly the same in Fish. There are some differences. But the alternatives are much easier to use. Check out the documentation for more information.
Man pages are a smart way to get more information about commands. But reading and searching for them are a pain. Fish comes to the rescue by opening man pages in web browsers. Give it a try.

- $ help set

Magic happens when you press Tab

Terminals usually autocomplete your half-written commands when you press the Tab key. Fish does that and a ton of other stuff. Here are a few snippets

> /geek @press{Tab}  /geekyway/
> ~/geekyway/v @press{Tab}
~/stuff/vipul.sh  (Executable, 4.8kB)  ~/stuff/vipul/  (Directory)
> ~/vipulgupta2048/ @press{tab} 
go/ 
aeious/ 
Android/ 
AndroidStudioProjects/
and 44 more rows

Keep pressing tab, shift+tab, arrow keys and other combinations to fully explore all the amazing features of Fish. Comment down below to let us know what cool new features you found while exploring.

Want to customize? Fish has you covered

Programmers love to customize their own personal setups be it desktop environments, text editors, and even terminals. I am no different. Hence when I found that you can customize Fish using a web browser and not write code for it. I was blown away. Try it out by typing

> fish_config

I can bet you haven't seen a smarter, more intuitive way to customize and change your terminal settings that include your prompt and its colors, change your functions, abbreviations and many other components.

Other Awesome Features

  • Syntax in Fish gets highlighted automatically.
  • Separating Commands (Semicolon)
  • Combiners (And, Or, Not)
  • Conditionals (If, Else, Switch)
  • And many more...

Sold Already, Make it default

To find the shells installed in your system, run this command.

> cat /etc/shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/tmux
/usr/bin/fish
/usr/local/bin/fish

You need to select "/usr/local/bin/fish" and then enter the command to change your default shell.

> chsh -s /usr/local/bin/fish

That's it now for the basics to get you started, I guess Happy Fish-ing !!

Share this post with your co-workers, batchmates, friends who struggle with using Bash, want a change, or just want to try new things.

More to come (Part 2- Tips/tricks of Fish and Writing Scripts for Fish)
Fork and star my dotfiles for more reference, and if you want the greeting message that I have on my terminal. - vipulgupta2048/dotvfiles/fish

© The Geeky Way. Built using Pelican. Theme by Giulio Fidente on github.

Disclaimer Privacy policy