How many Linux commands do you issue every week? If you're a Linux systems administrator, my guess is that number isn't trivial. Of those commands, how many can you remember off the top of your head? That number might well be trivial — especially, if you're like me and memory isn't exactly what it once was. I run quite a lot of commands on various Linux machines during the week and cannot always remember exactly the command I ran. That is why I depend upon a little bash utility called fish.
fish is a smart command line shell for Linux, UNIX, and macOS that offers:
- VGA Color
- Full scriptability
- Web Based configuration
- Man Page Completions
- Syntax highlighting
- And more
One of the most helpful features of fish is its ability to pull from your bash history to suggest commands. With this feature, you don't have to always commit to memory the commands you run or tirelessly scroll through your history to locate the command you need in the moment.
Let's install fish and see just how it works to make you a more efficient Linux administrator.
I'm going to be demonstrating on the Ubuntu Server platform how to install and use fish. If you head over to the fish page, you will see that you can subscribe to the developer's PPA. Unfortunately, this option doesn't work; so you'll have to install the application manually. Here's how.
The first thing you need to do is download the necessary files for your release. The files you will need are:
Download those three files into your ~/Downloads directory. Now, open a terminal window and install the package bc (an arbitrary precision calculator language) with the command:
sudo apt-get install bc
After that installation completes, change into the directory housing the .deb files with the command cd ~/Downloads. We now install fish with the command:
sudo dpkg -i *.deb
That's it, fish is now installed.
Using fish is quite intuitive; however, you must first change from your standard bash shell into the fish shell with the command fish. Once you've switched from bash to fish, you'll notice a subtle change to your command prompt (Figure A).
Start typing a command to see fish automatically make suggestions (Figure B).
If the suggestion is correct, hit the right arrow key on your keyboard to accept or the up arrow to start going through your history. A nice addition to the fish history is that it will only scroll through the history based on what you type. For example, if you start typing s and then hit the up arrow, fish will only display commands that include the letter s. If you type ssh and hit the up arrow, fish will only display those command which contain ssh. This makes for a very efficient means of searching through your bash history.
To exit out of the fish shell, simply type exit and you're back in bash.
This only scratches the surface as to what fish can do; to learn more about fish, type man fish and read through the official fish manual page.
Bash made friendly
Bash is an incredibly powerful shell that every Linux administrator should know. That doesn't mean you can't add a bit of user-friendliness to that power. With the help of fish, you can make bash as helpful as it is useful.
- How to manage tar files in Linux (TechRepublic)
- How to install applications from the command line using apt, dnf, and zypper (TechRepublic)
- 20 quick tips to make Linux networking easier (TechRepublic)
- How to install mycli for suggestion-based MySQL typing (TechRepublic)
- How to install Linux Mint on your Windows PC (ZDNet)
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.