DEV Community

Cover image for Rust-ify Linux/GNU/macOS terminal tools
Kingkor Roy Tirtho
Kingkor Roy Tirtho

Posted on

Rust-ify Linux/GNU/macOS terminal tools

Unix tools, generally written in C, are an exceptionally well-designed and maintained tool set for regular day-to-day terminal usage. Although these traditional GNU and Unix amazing, they are nowadays not enough and over 40-50 years old. So those were not designed keeping the modern computers & software in their mind. We need more cool fancier and feature rich tools that save time and also make us look savage

Rust to the saving

Rust, slowly taking place into the realm of modern computing and crazy terminal space, actually has some cool and brilliant solutions for the old GNU and Unix based CLI problems. Although it might sound weird and out of the world, but surprisingly there’s a Rust based equivalent (mostly upgrade) for every single basic CLI (Command Line Interface) tools in Linux/macOS. This kind of thing unseen in the days of computing

Enough goof and trash talk (I hate myself for this), let’s see all gems now

We’ll replace all the native terminal commands with their Rust equivalent using the alias property of the shell

cd replacement - Zoxide

A smarter cd command. Supports all major shells.

It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes.

So if you go to a directory e.g /home/batman/03842034sakdsuperrmanbadasd21/secret-identity once, the second you can just type z secret-identity it’ll directly navigate to that same directory

So let’s bury cd with zoxide. Just do:

  • open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias cd=z at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type cd ./<any-directory> and live happily every after

ls replacement - Exa

exa is a modern replacement for the venerable file-listing command-line program ls that ships with Unix and Linux operating systems, giving it more features and better defaults. It uses colors to distinguish file types and metadata. It knows about symlinks, extended attributes, and Git

Now, let’s unlist ls with exa. Just do following:

  • open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias ls=exa --icons --colors=always at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type ls <any-directory> and live a colorful life

grep replacement - Rip grep (Dude got humor XD)

ripgrep is a line-oriented search tool that recursively searches the current directory for a regex pattern. By default, ripgrep will respect gitignore rules and automatically skip hidden files/directories and binary files. In other word, RIP grep

Now, let’s execute (kill) grep and repalce with ripgrep. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias grep=rg at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • Type grep Life <any-file> and … (are you even a human?)

cat replacement - Bat

A cat replacement with syntax highlighting and Git integration and line numbers

Cat has nine lives. The cat command has exactly 10 replacement and bat is the 10th attempt at making a better cat (character at)

Image description

Now, let's kick off the ungrateful cat and replace it with bat. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias cat=bat at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type cat ./<any-file> and fly out in the night sky and sleep in the day

top repalcement - bottom🙃

Yet another cross-platform graphical process/system monitor. It’s a customizable cross-platform graphical process/system monitor for the terminal. No matter what system stats/monitor tool anyone makes/writes, it’d still be better than top

Image description

Now, let's remove top from the top and put bottom there

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias top=bottom at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type bottom and find out why Chromes taking the 99% of RAM

See kids, anyone(tool) can go from bottom to top

sed replacement - Sd

sd is an intuitive find & replace CLI and the sed butcher. sd uses regex syntax that you already know from JavaScript and Python. Forget about dealing with quirks of sed or awk - get productive immediately. It’s find & replace expressions are split up, which makes them easy to read and write. No more messing with unclosed and escaped slashes

Now, let's replace sed with sd. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias sed=sd at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • Example: type echo 'lots((([]))) of special chars' | sed -s '((([])))' '' and you’ll get the output as lots of special chars

cloc repalcement - Tokei

Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language. It’s a great replacement for cloc (count lines of code)

Now, let's count cloc off and use tokei instead. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias cloc=tokei at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type tokei ./ and it’ll output 0 lines of code ‘cause you didn’t write any

find replacement - Fd

fd is a program to find entries in your file system. It is a simple, fast and user-friendly alternative to find. While it does not aim to support all of find's powerful functionality, it provides sensible (opinionated) defaults for a majority of use cases.

It has an intuitive syntax: fd PATTERN instead of find -iname '*PATTERN*'. Supports Regular expression (default) and glob-based patterns. Superfast due to parallelized directory traversal. Uses colors to highlight different file types (same as ls). Ignores hidden directories, files & patterns from your.gitignore, by default. AND The command name is 50% shorter than find :-)

Image description

Now, let’s forget, find and replace it with fd. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias find=fd at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type find useful-files and forget

du repalcement - Dust

du + rust = dust. Like du but more intuitive. dust shows the disk usage more efficiently, fast and in a more organized way

Now, let's throw du to dust and replace it with dust. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias du=dust at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type du and see the reason why your disk space at 69% (I know it’s all Pokémon movies)

ps replacement - Procs

procs is a modern replacement for ps. It has colored and human-readable outputs. Supports Multi-column keyword search. Additionally, it shows TCP/UDP port, read/write throughput, docker container name, more memory information too which ps can’t show

Now, lets SIGKILL ps and replace it with procs. Just do following:

  • Open ~/.bashrc/~/.zshrc/~/. config/fish/
  • add alias ps=procs at the end of the file and save the file
  • close and open the terminal or run source <config-file-path>
  • type ps and to exit, press q

bash repalcement (more like powershell) - Nushell

A new type of shell. It’s an alternative shell, quite different compared to bash, zsh or fish like terminals. Instead of thinking of files and data as raw streams of text, Nu looks at each input as something with structure. For example, when you list the contents of a directory what you get back is a table of rows, where each row represents an item in that directory. These values can be piped through a series of steps, in a series of commands called a 'pipeline'. (~ copied from the official doc)

It supports plugins which interacts with Nushell using JSON-IPC. Plugins are basically binaries available in the path and follows the nu_plugin_* naming convention

Nushell is extremely powerful and flexible and brings organization to the outputs. It structures the output in an intuitive and human-readable way. Nushell is basically the non-corporate open-source terminal, but keeping the UNIX spirit. It’s more like a PowerShell replacement. But in Linux/macOS it shines bright too. It needs more adaptation and updates and let's keep our finger crossed hoping it’ll one day become the top shell of all time

Nushell supports all major platforms (Linux, Windows, macOS). Now install it and then run chsh -s $(which nu)

Without sudo it should work. If you use sudo it will change the shell not for your working user but for root. Finally, log out of your computer and log back in.

What? You want more?

All the configurations at once for replacing the GNU/Unix tools. Put this on ~/.bashrc / ~/.zshrc etc shell configuration files and restart your Terminal

alias cd=z
alias ls=exa --icons --colors=always
alias cat=bat
alias find=fd
alias grep=rg
alias du=dust
alias sed=sd
alias cloc=tokei
alias ps=procs
Enter fullscreen mode Exit fullscreen mode

Well, you can always support me for more 😊

Buy Me A Coffee


Follow me on:

Top comments (2)

horaciodegiorgi profile image
Horacio Degiorgi

nice tools selection. Bottom is new for me .

friendbear profile image
T Kumagai

Thank you for the consistently valuable information.

Let me introduce myself in the Apple community.
I am actively participating in the open Apple community, eager to provide support whenever possible.

I have a great love for Apple products and would like to contribute my time to support others. If there's anything I can assist you with here as well, please feel free to let me know. Thank you in advance for your consideration.