#!/Hash/Bang/Wallop

Rusty Command Line Tools

Introduction

Rust is quickly cementing itself as the language of choice for writing system tools largely due to its speed and memory-safety. There is now a large amount of 'new breed'; CLI tools that are written in Rust that are awesome, these are the tools that I use, many of them have completely replaced their standard system counterparts, for example on my local machine I never use grep anymore and prefer Ripgrep instead.

You can see my config for many of these tools in my dotfiles.

Alacritty

Alacritty is now my terminal emulator of choice after lengthy stints with st and before that rxvt-unicode. Alacritty is fast, largely due to it using the GPU for rendering, on their Github page they reference a benchmarking tool vtebench which I gave a try myself just out of interest, these are my results from hyperfine --show-output "cat target/benchmarks/scrolling.vte":

Benchmarks

Alacritty

Time (mean ± σ):      1.699 s ±  0.026 s    [User: 0.1 ms, System: 1698.9 ms]
Range (min … max):    1.665 s …  1.747 s    10 runs

xterm

Time (mean ± σ):     159.961 s ±  1.693 s    [User: 1.1 ms, System: 5882.7 ms]
Range (min … max):   155.219 s … 160.984 s    10 runs

urxvtc

Time (mean ± σ):      1.709 s ±  0.027 s    [User: 0.5 ms, System: 1709.5 ms]
Range (min … max):    1.689 s …  1.768 s    10 runs

st

Time (mean ± σ):      4.134 s ±  0.471 s    [User: 0.0 ms, System: 4085.8 ms]
Range (min … max):    3.717 s …  4.863 s    10 runs

Thoughts

It was surprising to see rxvt-unicode competing so well.

Configuration of Alacritty is done via a simple TOML file, you can see my ~/.config/alacritty/alacritty.toml as an example.

bat

bat is a replacement for cat and a pager such as less that has support for syntax highlighting and has Git integration too. I often use it to quickly output a file so I can cut 'n' paste the contents to somewhere like work's Slack but by default it was outputting some extras such as line numbers and a table-like UI, I turned these off and set a colour theme that better suited my terminal's colours with:

# ~/.config/bat/config

--theme="ansi"
--style="changes"

Lastly, if bat doesn't already support syntax highlighting for the type of file you are looking at it can easily be added, I added Terraform highlighting which is what you can see in the screenshot, you can see how to do that here: ~/.config/bat/syntaxes.

bat displaying some Terraform code
Figure 1: bat displaying some Terraform code.

bottom

Bottom, or btm which is the command, is a fancy alternative to top or htop. You can customise most elements of the output with a TOML file, I had to change a bunch of colours as some elements weren't visible with my terminal colours.

Example btm output
Figure 2: Example btm output.

dust

dust is a more intuitive alternative to <code>du</code>, it also shows a fancy graph so you can easily spot what is gobbling up all your disk space.

Example dust output
Figure 3: Example dust output.

eza

eza is the maintained fork of exa, it is an alternative to ls which I'm using via aliases alias l='exa -agl --git'. Exa has colours for filetypes and pretty much everything else, in fact it has so many colours I had to turn some off as separate colours for each permission bit is a tad too much, you can do that with:

export EZA_COLORS="uu=0:gu=0:ur=0:uw=0:ux=0:ue=0:gr=0:gw=0:gx=0:tr=0:tw=0:tx=0"  

eza also has support for git and will show in the listing if items have been modified, are ignored, or are new to the Git repo. Lastly, eza also has the -T flag which is essentially a more powerful replacement for tree.

Example eza output
Figure 4: Example eza output.

fd

fd is a user-friendly alternative to find, no having to remember that you put the directory to search in before the search term, no remembering the weird -name ... or -type d flags. fd is also fast even when searching over the entire filesystem.

hyperfine

hyperfine is similar to time but it shows you a fancy progress bar, it also runs the thing you are timing multiple times, 10 times by default, it then gives you the average and the min/max range. hyperfine is what I used to time the terminal benchmarks I have in the Alacritty section.

Example hyperfine output
Figure 5: Example hyperfine output.

ion

Ion is not really a tool but it is getting an honourable mention as it is a new shell written in Rust, it is part of the Redox OS which is a full Unix-like operating system completely written in Rust. Ion does not aim to be POSIX compliant but has some interesting ideas such as type checking function arguments, and arrays and hashmaps that are much more similar to what you're used to with programming languages.

Ion is still considered an ‘alpha’ release, I did switch to it as my default shell but I had a few niggles with it and eventually moved back to zsh. A bunch of my issues stemmed from integrating with other helper scripts that probably weren't working properly due to the lack of POSIX compliance, a minor issues was having to keep remembering to use quotes when doing a command that had @ in it such as ssh or git repo cloning, the @ sigil is used for arrays in Ion so without quotes it would get confused. Lastly, and my biggest issue with Ion was the lack of autocompletion, it has some basic completion but even then it shows things like env vars when you're trying to cd into a directory; I couldn't see any way to add custom completion currently, I'm sure that is on the roadmap.

licensor

Stop looking up open source licenses for your projects and then cut 'n' pasting, licensor quickly outputs a variety of OSS licenses to stdout.

procs

procs is a replacement for ps, it has support for some stuff that ps doesn't such as TCP/UDP ports and Docker container names, the output is a bit nicer and there is also a watch mode and tree view.

Example procs output
Figure 6: Example procs output.

rage

rage is the Rust implementation of age which is a simple, modern and secure encryption tool with small explicit keys, no config options, and UNIX-style composability. It aims to be a modern and simpler replacement for tools such as gnupg.

ripgrep

Ripgrep, or rg which is its command is a replacement for grep and recursive search tools like Ack and The Silver Searcher, it is fast and is one of the first things I install on a new machine these days. Ripgrep can be integrated into most text editors.

sd

sd is a more intuitive alternative to sed and is now my go to tool when ordinarily I would have reached for sed. It also looks to be a lot quicker than sed if the benchmarks on their readme are accurate.

Skim

Skim, or sk is a fuzzy finder which is similar to fzf. Skim has keybindings for your shell that are unashamedly pinched from fzf such as ctrl-r for reverse searching command history which is what is shown in the screenshot. Skim can also be integrated with your text editor such as Vim. You can customise the colours and output via setting default options in an env var, I've tweaked the colours a little bit and changed it so that the interface shows below the command rather than above:

export SKIM_DEFAULT_OPTIONS='--layout=reverse --color=light,fg:8,bg:15,current_bg:7,matched_bg:10,current_match:8'
Example skim output
Figure 7: Example sk output.

Starship

Starship is a prompt for your shell, it is cross platform and much faster than previous alternatives I've used. I have used other tools in the past mainly for showing git status in my shell, you can definitely feel a slight slow down with those, I don't notice it at all with Starship. You can customise the prompt with a fairly intuitive TOML file. Starship does much more than just git status though, it has modules for all sorts. By default it uses emojis for things which I find a bit over the top so I've switched to using simpler icons via Nerd Fonts, the prompt you can see in all of the screenshots is Starship using the Fira Mono Nerd font, you can see the rest of my Starship config in my dotfiles.

tokei

tokei is a very simple tool that shows various stats about the code in your project.

Example tokei output
Figure 8: Example tokei output.

Zoxide

Zoxide gives you a z command that allows you to quickly jump to frequently used directories. It is similar to z which is written in shell, it will build up a history of your most frequently used directories and will then fuzzy match them when you try to jump to them. For example I work on Terraform code for work a lot that lives in ~/code/terraform/infrastructure-as-code, no matter what directory I'm currently in I can quickly jump to there with z infra. Zoxide also has a fancy fuzzy search integration with fzf, I'd really like the option to use Skim instead but the project maintainer currently does not want to switch to Skim as the default despite it also being written in Rust as Skim currently does not work with Windows, some way to choose between the two would be the best of both worlds.