Seven ridiculously good command line tools
Tags: commandline, unix, linux, firstpost
Published: 2019-07-03 19:09:47

<small>***Originally posted on [listnux.com](https://www.listnux.com/blog/seven-ridiculously-good-command-line-tools/)***</small>

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](#cheatsh)|
| [Rebound](#rebound)|
| [mycli](#mycli)|
| [Bat](#bat)|
| [Fiche - termbin.com](#fiche)|
| [GRV](#grv)|
| [GoAccess](#goaccess) |

### <a name="cheatsh"></a>1. [cheat.sh](https://github.com/chubin/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](https://cheat.sh/).

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

```sh
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](https://www.listnux.com/static/pictures/20190702-1.jpeg)

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:

```sh
cht.sh python sort dictionary by value
```

![Screenshot of terminal output of above command](https://www.listnux.com/static/pictures/20190702-2.jpeg)

Notice the link at the end (`so/q/613183`)? It stands for [https://stackoverflow.com/q/613183](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:

```sh
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](https://stackoverflow.com/q/52141785)

<small>[cheat.sh](https://cheat.sh/) • [View on GitHub](https://github.com/chubin/cheat.sh)</small>

---

### <a name="rebound"></a>2. [Rebound](https://github.com/shobrook/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 StackOverflow, but, why waste time typing a long error, when you can use [Rebound](https://github.com/shobrook/rebound)?

[Rebound](https://github.com/shobrook/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:

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

And here is what happens:

![Screenshot of Rebound pulling an error code](https://www.listnux.com/static/pictures/20190702-3.jpeg)

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

![Screenshot of Rebound pulling Stack Overflow questions](https://www.listnux.com/static/pictures/20190702-4.jpeg)

Fantastic? Absolutely!

<small>[View on GitHub](https://github.com/shobrook/rebound)</small>

---

### <a name="mycli"></a>3. [mycli](https://github.com/dbcli/mycli) - A terminal client for MySQL

[mycli.net](https://www.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](https://www.listnux.com/static/pictures/20190702-5.gif)

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:

```sql
\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:

```sh
\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](https://github.com/dbcli/pgcli) project for Postgres


<small>[mycli.net](https://www.mycli.net/) • [View on GitHub](https://github.com/dbcli/mycli)</small>

---

### <a name="bat"></a>4. [Bat](https://github.com/sharkdp/bat) - a cat clone with winds

[Bat](https://github.com/sharkdp/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](https://www.listnux.com/static/pictures/20190702-6.jpeg)

**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](https://www.listnux.com/static/pictures/20190702-7.jpeg)

<small>[View on GitHub](https://github.com/sharkdp/bat)</small>

---

### <a name="fiche"></a>5. [Fiche](https://github.com/solusipse/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:

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

The terminal returns a simple URL: [https://termbin.com/wf6u](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](https://github.com/gleitz/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](https://termbin.com/) is a public pastebin server that works with the commandline pastebin tool [fiche](https://github.com/solusipse/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](https://l.termbin.com/wf6u)).

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

<small>[termbin.com](https://termbin.com/) • [View on GitHub](https://github.com/solusipse/fiche)</small>


---

### <a name="grv"></a>6. [GRV](https://github.com/rgburke/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](https://github.com/rgburke/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](https://www.listnux.com/static/pictures/20190702-8.jpeg)

**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).

<small>[View on GitHub](https://github.com/rgburke/grv)</small>

---

### <a name="goaccess"></a>7. [GoAccess](https://github.com/allinurl/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](https://www.listnux.com/static/pictures/20190702-9.jpeg)

This is awesome, cause the `access.log` logs on most servers are hard to read and even harder to analyse quickly. [GoAccess](https://goaccess.io/) will allow you to have visitor statistics for your website without tracking your visitors, [compromising their privacy](https://www.listnux.com/blog/six-biggest-offenders-of-the-right-to-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.

<small>[GoAccess](https://goaccess.io/) • [View on GitHub](https://github.com/allinurl/goaccess/)</small>

### [Bonus] [wttr.in](https://github.com/chubin/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](https://www.listnux.com/static/pictures/20190702-10.jpeg)

Nope, not a single cloud. Nice!

<small>[wttr.in](https://wttr.in/) • [View on GitHub](https://github.com/chubin/wttr.in/)</small>