Your terminal can be much, MUCH more productive 💻

What about drastically reduce the time spent on daily tasks in terminal? 😉

Portuguese version: https://medium.com/@ivanaugustobd/seu-terminal-pode-ser-muito-muito-mais-produtivo-3159c8ef77b2

Our goal

A terminal that can pratically predict what you want to type, save a lot of repetitive commands, give you a really powerful autocomplete, let you search for files using Ctrl+T like in your editor/IDE and have a pretty visual!

Seriously, try this be yourself to see what we’re talking about! :D

The prints below will have a different visual of the video above because I’ve created a VM with a (almost, I’ve changed the theme) clean install of a Fedora spin, to guarantee that nothing would be forgotten.

Although that was written using Fedora, it probably will work in any Linux distro (or even BSD and MacOS)..

Update: Marc Pires and Beto Alves just confirmed (here and here, respectively) that it works with MacOS too!

Don’t worry about the names that maybe you don’t know (yet), just carry on and you will see that it’s simple 🙂

Let’s start!

1°) ZSH. For now, you just need to know that it is a shell ridiculously customizable that will allow us to do what we want.

In all OSs that I’ve tested/used, the package name is zsh, so just install it using your system’s package manager:

2°) Oh My Zsh. It will bootstrap the ZSH setup for you (during the installation, it will ask for your password, but that is just to set ZSH as your default shell):

If all goes right, you will see that screen now:

Image for post

If it don’t show you the message “Shell changed.” just before the Oh My ZSH logo, maybe the script wasn’t able to change your default shell. In that case, you can manually change it using sudo usermod --shell $(which zsh) <your_username> .

If you just open another terminal tab it will still using your older shell, but the next time you login in your system it will be ZSH already.

Ok, now you already has an ridiculously powerful autocomplete! Try typing git <something> (or another thing that you use) and press <TAB> a couple of times to see all available options:

Image for post
git related suggestions

If the command that you tried won’t offer that suggestions, probably there will be a plugin for it. In any case, to enable a plugin, you just need to open the file ~/.zshrc add it in the plugins=(...) line. For example, to enable the dnf plugin:

Image for post

For now on we will dive into visual and functional parts, and in any of it you just need to reopen your terminal or use source ~/.zshrc after each change to see it working immediately. Or.. you can just to everything and restart it just one time.

Functional — let’s put a s̶m̶i̶l̶e̶ ̶o̶n̶ ̶t̶h̶a̶t̶ ̶f̶a̶c̶e̶ lot of cool features in!

1°) zsh-syntax-highliting. Basically it make the command green if typed right, red if doesn’t, and underline existent folders/files.

Now add zsh-syntax-highlighting in your plugins list:

Image for post

Now you’ll have something like this:

Image for post
Correct commands in green, nonexistent in red, files/folders with underline and strings in orange

2°) zsh-autosuggestions. Autocomplete suggestions based in your history. That’s really useful for docker run , php artisanand mageruncommands!

Image for post

Now you will have something like that when typing a command for the second time:

Image for post
Use Ctrl+→ (right) to accept the next word or simply → to accept the whole command

3°) fzf. Simply a FUZZY FINDER IN YOUR TERMINAL!!

Remember to answer “y” to all questions!

Image for post

Now you can use Ctrl+T to search for files, like in your editor!

Image for post
Suggestion: add support to .gitignore for faster results in large projects 😜

Oh, you can now search for commands in your history too using Ctrl+R!

Image for post
It deals well even with some typo

Visual — what about a sexy terminal?

The channel baby Wogue has just made a video that show how to do what we’re about to do ><

1°) Nerd Fonts. An “iconic font aggregator”, will some of the most popular monospaced fonts patched to support icons! Go to the Downloads section in their site and pick your favorite (personally I really like the Hack font for use in terminal, specially because it was made for it).

Now extract it and move the files into yours fonts folder (something like ~/.fonts or ~/.local/share/fonts):

And now changed to it in your terminal (something like Preferences->Appearance->Font):

Image for post
Choose the “<font> Nerd Font Regular” variant

Now you have support to our next step — icons in your terminal.

2°) Powerlevel9k. A theme that supports icons and A LOT of customization, besides saving you some repetitive commands like git status because it show will some info about your project/system already 😆

UPDATE: you can use Powerlevel10K too; it’s a drop-inreplacement but faster

Now to enable it, change your ZSH_THEME (in the ~/.zshrc file) to powerlevel9k/powerlevel9k and add POWERLEVEL9K_MODE="nerdfont-complete" to add support for icons:

Image for post

Close and reopen your terminal and voi lá!

Image for post
In that part maybe will be interesting to you to change your terminal color-scheme for better legibility 😉

For default it shows your-username@host , followed by your actual path and the status of the project. And.. that is fully customizable! Take a look on their showcase to pick some ideas 😉

You can custom it just by adding POWERLEVEL9K_LEFT_PROMPT_ELEMENTS = (...elements) and/or POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS = (...elements) your ~/.zshrc file, like that:

Image for post

And when you launch your terminal again, well, just take a look at that:

Image for post
Pretty cool, right? :D

All custom options are available here.

Now, when you add/edit/delete a file, change branches/tags or stash things, it will automatically change to show you what has made:

Image for post

If you want more ideas, take a look here. 😉

Bonus

1°) Aliases. Basically a bunch of shortcuts to most used commands. Just add alias shortcut="command" in your ~/.zshrc file. Some ideas:

With that your can run docker command as d run , mysql as m -v < dump.sql , gulp watch as simply gw and so on, use your imagination! Just remembering that some plugins (like Composer and DNF) already add some alias to you 😬

2°) Tilix. A lightweight terminal with support for tilling/split and some modern themes built-in!

Image for post
Print with “Material” theme

3°) Notifications. enabling the plugin “bgnotify”, any commands that are done in background will generated a system notification (useful for long-time commands, like laravel new <project>, npx create-react-app <project> and updates like composer update ou yarn upgrade):

Image for post
Really cool \o/

4°) ColorLs. Just install it and create an alias alias ls="colorls --sd -A" and you will have a “iconic” ls:

Image for post
Image for post

The closer that I could came to that in it was using Oh My Fish + bobthefish theme:

But.. it don’t end up with all those features 😝

Concluding

I hope that you reduce drastically the time spent in the terminal with that :D

Written by

The one and only real “fix” of any problem is to purge its cause.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store