Cursus — a systemwide Bash/Zsh/* command line history

Mario Kleinsasser
Panoptikum
Published in
3 min readSep 11, 2020

--

Always losing your command line history when working with multiple shell windows? My colleague has written a cure against it which will help you to never lose your history again! I’ve often more than 30 shells open and without utility support, this is hard to handle because the CLI history is always overwritten by the last closing shell. Read on to know how you can have the same comfort too!

Made by Stefan Ringhofer

Some years ago we had the idea to write a tool that collects every command typed into a Bash shell into an SQlite database. The benefit of a database is, that every shell where you type in a command writes into the same database without overwriting the existing data. Furthermore, it is possible to use a timestamp to have the data order in chronological order and the best of all is, that it is also searchable. Back then we wrote a tool called historian but this was outdated.

This year, my colleague Stefan Ringhofer (Twitter, LinkedIn), who also made this lovely logo, reworked the tool and re-released it on our homepage as cursus. cursus is Latin and means something like track or progress. You can find the source code and the binary on our GitLab project page: https://gitlab.com/n0r1sk/cursus

How does it look like?

To show you how simple it is to use, I made a little Asciinema of it. Asciinema is a beautiful tool to make screencasts from console terminals.

Asciinema converted to gif with asciicast2gif

Howto work with cursus

The installation is straight forward. Just head over to https://gitlab.com/n0r1sk/cursus and follow the quick installation guide. If you would like to install it manually, you will find the instructions also there. After you have installed cursus into your path, it is simple to use. Here is the help output of the tool:

usage: cursus search [<flags>] [<criteria>...]
search for a command
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--debug enables debug
-p, --paste paste the nth last command from the history to your console
-e, --execute execute the nth last command from the history to your console
-n, --n=0 specify which command should be either pasted or executed. Order is bottom to top (default last=0)
Args:
[<criteria>] criteria you want to search for

Takeaways

Many thanks to Stefan Ringhofer who reworked the tool! Now it is much more stable and easier to use.

cursus makes our work much easier! It helps us to have a lot of terminals open at the same time without overwriting the history every time! Try it out!

Last edited on 11th September 2020

--

--

CTO @Nordcloud, an IBM company Austria, Speaker, GitLab Hero, Docker Community Leader, Author, Cloud Architect — 𝗜𝗺𝗮𝗴𝗶𝗻𝗮𝘁𝗶𝗼𝗻 𝗶𝘀 𝗺𝗼𝗿𝗲 𝗶𝗺𝗽𝗼𝗿