Seven ridiculously good command line tools

Insanely useful command line tools to make your life easier without you ever needing to leave the terminal.

You are coding in Python. Your screen is filled up with terminals of various sizes and lenghts, and you have a deadline. It is 2.00 am, winter, the room is chilly, and there is a storm outside.

You have a big dictionary, and you want to sort it by a numeric value. How to do this? You turn your head around the screen, to spot your favourite browser, and to ask your friends, Google, or StackOverflow. You know the browser is there, it has always been there for you. But all the terminals all over the screen cover it completely. You curse your decision to use a window manager without taskbar and frantically start moving and minimising terminals.

Well, you are in luck. You might not need to.

Ridiculously good command line tools

Contents
cheat.sh
Rebound
mycli
Bat
Fiche - termbin.com
GRV
GoAccess

1. cheat.sh - the only cheat sheet you need

A cheatsheet that let's you access not only actual cheatsheets and simple overviews of various commands and programming languages, but it even queries Stack Overflow for answers? And automatically selects the most upvoted thread that matches your search term? Yes, that's cheat.sh.

To find out what Stack Overflow has to say about our previous question, without leaving the terminal, is as simple as:

curl cheat.sh/python/sort+dictionary+by+value|more
# OR
curl cht.sh/python/sort+dictionary+by+value|more

Screenshot of terminal output of above command

Alternatively, you can install the command line client, cht.sh, so that you don't even have to type curl, or add + between the terms:

cht.sh python sort dictionary by value

Screenshot of terminal output of above command

Notice the link at the end (so/q/613183)? It stands for https://stackoverflow.com/q/613183 and it is the most upvoted question in Stack Overflow that contains the queried terms. Say, though, the most upvoted question does not answer your specific issue (though this particular answer is excellent)? Simply extend a /1 or /2 or any number at the end of your query. For instance:

curl cht.sh/python/sort+dictionary+by+value/1
#or
cht.sh python sort dictionary by value/1

will return the top answer to this Stack Overflow question

cheat.shView on GitHub


2. Rebound - Command-line tool that instantly fetches Stack Overflow results

So, with the help of cht.sh, you figured out the answer of your question and finished a part of your project. So you run it, and, whoa... compile error. You can still type the error for cht.sh to fetch an answered question from Stack Overflow, but, why waste time typing a long error, when you can use Rebound?

Rebound is a fantastic Python tool, that allows you to simply execute the file and directly pull the error message and find related Stack Overflow questions. It works with Python, Ruby, Java, Goland and Node.js and it is as simple as:

# instead of typing:
python app.py
# you simply type:
rebound app.py

And here is what happens:

Screenshot of Rebound pulling an error code

Once you press enter, you get a list of related Stack Overflow threads:

Screenshot of Rebound pulling Stack Overflow questions

Fantastic? Absolutely!

View on GitHub


3. mycli - A terminal client for MySQL

mycli.net, at first glance, might not seem as sexy as the previous tools, but it is insanely handy when you are working with MySQL databases.

Gif animation displaying mycli.net shell in practice

It packs auto-completion for SQL keywords and tables, views or columns, logs, colourful tabular data, multiline queries and more.

But what's more, it permits you to save complex (or simple) queries as aliases for future use. It allows parameter substitution for your saved queries, so you can reuse them whenever applicable.

For example, I have saved a query, which generates a DROP statement for tables starting with a certain string:

\fs cleardb SELECT CONCAT( 'DROP TABLE ', 
                            GROUP_CONCAT(table_name) , ';' ) AS statement FROM
                            information_schema.tables WHERE table_schema = '$1'
                            AND table_name LIKE '$2__%';

with $1 being my database name and $2 the string I want my query to match on the table name. Simply invoking the alias with:

\f cleardb "my_database" "my_string_"

will return the drop statement I need. You really don't realise how much you are missing a tool like this, before you actually try it.

Also see the pgcli project for Postgres

mycli.netView on GitHub


4. Bat - a cat clone with winds

Bat is a Rust tool that aims to be the better, prettier and more handy replacement of cat(1). It features syntax highlithing, line numbering, theming, pagers, and it communicates with Git to display file modifications.

Screenshot of bat using markdown syntax highlighting

Bat can completely replace cat and it can be used in pipes (bat .bash_profile |grep PATH), or with find: find -type f -name README.md -exec bat {} +

Screenshot of bat previewing find results

View on GitHub


5. Fiche - termbin.com

You were still coding that Python script, remember? And decided to share a file with your friend.

Now, you can login to GitHub and post a gist, or to GitLab and post a snippet, or to Pastebin. But, yeah, your browser is hidden below a few stacks of terminals. So, what can you do?

This:

cat test_howdoi.py | nc termbin.com 9999 # or 'bat test_howdoi.py...'

The terminal returns a simple URL: https://termbin.com/wf6u in the above case. You text this URL to your friend, and, behold, you just shared your file, without ever leaving your terminal. (In case you are wondering, I shared a file from howdoi, a fantastic command-line tool, which is not in the current list, as it has a bit similar function with the first two tools listed).

Termbin.com is a public pastebin server that works with the commandline pastebin tool fiche. It is very quick, keeps pastebins for a month and even has syntax highlighting (try the above link with l.termbin instead of termbin: l.termbin.com/wf6u).

What's more, you can install fiche and self-host your own pastebin server.

termbin.comView on GitHub


6. GRV - terminal interface for git

Sometimes you don't know anymore what's going on on your local git repo. You remember that your last few commits were "Fix #1999", "Prev fix broke things, revert to #1998", "Fix #2000", "revert Fix #2000", "final fix", "%#&@ this I go to sleep", but you need to see what files you changed on each commit, the diffs, the commit messages.

And of course git allows you to do all of this. And of course, there is an even easier way, to see all your commits, diffs and refs on a nice, easy to browse table.

"Yes, *I know* ", you say, "it is called *GitHub*. I need to dig out that browser".

Or you can simply use GRV. It presents all the above info on a nice table right on your terminal. It has tabs and splits and custom views, queries, and your terminal refreshes automatically whenever there is a change on the filesystem.

GRV on a terminal

GRV is a tool you don't realise how much you need it, until you actually use it. It makes the presentation of your git repo so easy to grasp and browse, that it is a must-have tool if you work with Git a lot (and you should work with Git all the time, if you are coding).

View on GitHub


7. GoAccess - real-time web log analyzer

One of these things is not like the others. The last tool on today's list is not going to help you in your coding adventures. But, if you have a website, it will analyse the logs of your web server and allow you to view them directly on your terminal.

GoAccess web log analyser screenshot

This is awesome, cause the access.log logs on most servers are hard to read and even harder to analyse quickly. GoAccess will allow you to have visitor statistics for your website without tracking your visitors, compromising their privacy and sharing their browser habits with big Internet monopolies.

It's meant to satisfy a simple curiosity about how many people visit your site and what pages they view. It's not a tool to replace Google Analytics, or Piwiq/Matomo, or Statcounter. It is meant to simply present nicely the logs your web server already keeps.

GoAccessView on GitHub

[Bonus] wttr.in - the right way to check the weather

So, is this storm still going outside? You can't hear any rain dropping on your windows, but you can't be sure without leaving that terminal (or that chair). Why don't you simply curl wttr.in or curl wttr.in/YOUR-LOCATION?

wttr.in screenshot

Nope, not a single cloud! Nice!

wttr.inView on GitHub