DEV Community

Anthony Symkowick
Anthony Symkowick

Posted on • Originally published at symkowick.org on

Does Your Terminal Spark Joy?

While the list of development tools we have to choose from grows every day, thehumble unix terminal beckons us with simplicity and the promise of adistraction-free experience. Once you’ve conquered the initial learning curveof navigating a command-line interface, you may be craving some sugary featuresyou gave up ditching IDEs (Integrated Development Environments). Surely theremust be some middle ground between a lone blinking cursor and clunky GUIs(Graphical User Interfaces)!

Read ahead for some helpful reimagininings of classic Unix tools.

1. man & tldr

First I’d like to share the tldr command, which provides a “just get me upand running” familiarity with many unix commands. Inspired by the man command to read manual pages for a program, tldr is much more concise and showscommon one-line examples of how a program is used. Yes, you should still readthe man page, but this can save you some time.

Compare the results below for Hugo, a static site generator:

$ man hugo

Enter fullscreen mode Exit fullscreen mode

man

lots of info there…could be a while!

$ tldr hugo

Enter fullscreen mode Exit fullscreen mode

There we go! Immediately I know how the developer of hugo intends me to use it -just type hugo new site in any directory I’d like to create my website.

tldr

2. Cat -> Bat

The Cat command is pretty muchunavoidable when working with the terminal - it allows concatenation of files(and printing them to standard output) and is the most common way to simplyspit out the contents of a file!

If I wanted to see the contents of a JavaScript file, I would simply:

$ cat example.js

Enter fullscreen mode Exit fullscreen mode

and we would get the contents of the file, simply and without fanfare:

cat

This is great, but the bat command improvesreadability of code by adding line numbers and syntax highlighting, all withoutsacrificing POSIX compatibility for piping into other programs.

$ batcat example.js

Enter fullscreen mode Exit fullscreen mode

bat

Awesome! It even opens in a pager (like the less command) for verticalscrolling. If you want this functionality by using the same keyword - cat - youcan set up an alias in your shell. I use zsh, and havealiased bat as follows:

alias cat="batcat -n --color auto --style full"

Enter fullscreen mode Exit fullscreen mode

3. du -> dust

The du command shows disk usage and can be used to determine whichdirectories are taking up the most space - useful when you’ve run out of saidspace!

$ du

Enter fullscreen mode Exit fullscreen mode

du

er, ok, looks like we are listing folders and files with numbers prepended totheir entries. Hmm. You can see that it’s gonna take some grokking to make sense of thisdata.

Let’s try the rust replacement, dust - like du but more intuitive, (straight from thetool website)!

$ dust

Enter fullscreen mode Exit fullscreen mode

dust

Wow, right away we are given a hierarchical view of the items within theDownloads folder - accompanied by a graph of size by percentage - or how much ofthe total folder size each subfolder is responsible for. Neat! Looks like thatrecent free dump of Springer Textbooks is takingup 68%! Do I really need all those books??

Dust is great for finding size of files, but how about our primary interfacefor dealing with files and directories in the shell?

3. ls -> exa

ls is the simple “show me what you got” program to list all items in adirectory. It has some helpful options to enable showing hidden/dot files, filesizes, permissions, and more. The below example will show off listing all(including hidden) files in the -l long format to get those other items Imentioned.

$ ls -la --color

Enter fullscreen mode Exit fullscreen mode

ls

This looks all right, and ls is pretty configurable as far as output formats.However, with exa we get some enhanced color andsane defaults.

$ exa -la

Enter fullscreen mode Exit fullscreen mode

exa

See how the permissions and owners are also color-coordinated? Nice. The exawebsite also notes that exa runs in parallel, so you might see much fasterperformance working in huge directories.

Those are just a few handy tools I’ve been exposed to recently that I thinkmight help you. The year is 2020, and we can live in whatever time we want -a splash of 1970 with Cool RetroTerm mixed with powerful 2020tools! If you enjoyed this post, please let me know, and if you have anyquestions or noticed a mistake, feel free to reach out! If you read throughthis blog post and thought, man, I’ve already known about these for years and Ibreezed through this refresher, kudos to you, friend! But I’ve got somethingfor you too - check out Nushell, it fits the themeof this blog post but expands it to the whole shell itself. Nushell toutscomposable tables as the primary method of interaction as opposed to totallyunstructured text.

Top comments (0)