avatarShinichi Okada

Summary

The article introduces Rust-powered command-line utilities that enhance productivity and performance for terminal users.

Abstract

The author of the article discusses the advantages of using modern, Rust-powered command-line utilities as alternatives to traditional Linux commands. These utilities, including dust, dutree, hyperfine, skim, sd, ytop, and bottom, offer improved speed, user-friendliness, and functionality. The article provides an overview of each tool, demonstrating their usage and benefits, and encourages readers to integrate them into their workflow by installing them via Cargo, Rust's package manager. The author also suggests creating aliases for seamless adoption and shares benchmarks to showcase the performance gains of these Rust-based alternatives.

Opinions

  • The author believes that Rust-powered tools are superior in terms of speed and modernity compared to traditional Linux commands.
  • Installing Rust and using Cargo for installing these tools is recommended by the author for ease of use and integration.
  • The author is enthusiastic about the productivity gains these tools offer, emphasizing their simplicity and effectiveness.
  • Creating aliases for Rust-powered utilities is advised to maintain familiarity with Linux commands while leveraging the benefits of the new tools.
  • The author values the community's input, inviting readers to share additional Rust-powered utilities they might know of.
  • Performance benchmarks are presented to validate the author's opinion on the efficiency of Rust-based tools over their counterparts.

Rust-Powered Command-Line Utilities to Increase Your Productivity

Modern and Fast Tools Under Your Belt

Image by the author
Table of Contents
Introduction
1. du alternatives: dust and dutree
  ∘ dust
  ∘ dutree
2. time alternative: hyperfine
3. A fuzzy finder: skim
4. sed alternative: sd
5. top/htop alternatives: ytop and bottom
6. A Bonus Tip
Conclusion

Introduction

Last month, I wrote an article sharing seven Rust-powered command-line utilities.

Those are modern and fast tools you can use every day with your terminal.

Since publishing that original article, I’ve been searching for more Rust-powered command-line utilities, and I discovered more gems that I’m excited to share with you today.

These tools will help you be productive with your terminal work.

I recommend installing Rust. When you install Rust, it will install Cargo as one of the toolchains. And you can install Rust-powered tools with Cargo.

If you want to start learning Rust, this article can help you get started.

Let’s dive in.

du alternatives: dust and dutree

dust

In Linux, the du command estimates file space usage. dust and dutree are Rust-powered du alternatives.

It is difficult to use du command for me. For example with du, listing files and folders and totaling the size including subfolders I use:

$ du -sk * | sort -nr

Dust gives you an instant overview of directories and its disk space and commands are simpler.

For example

$ dust
$ dust <dir>
$ dust <dir>  <another_dir> <and_more>
$ dust -p <dir>  (full-path)

You can find all the usage here.

dust result for ~/.cargo directory. Image by the author

In the above image, you can see that the app directory occupies 57MB(29%) and the target directory occupies 139 MB (71%) of disk space.

You can install dust with Cargo.

$ cargo install du-dust
$ dust --help

You can find other installations here.

dutree

dutreeis another du alternative to analyze disk usage.

You can install dutree with Cargo.

$ cargo install dutree

You can find usage by dutree --help.

dutree has also simple command options. For example, you can display directories using the -d option to different directory depth.

$ dutree -d // the default is 1
$ dutree -d2 // show directories up to depth 2
dutree result. Image by the author

time alternative: hyperfine

In Linux, the time command shows you how long a given command takes to run. It is useful for testing the performance of your scripts and commands.

Let’s say you have two scripts or commands doing the same job. You can use the time command to compare the time required for these scripts.

hyperfine is a Rust-powered, time alternative, command-line benchmarking tool.

Installing it with Cargo:

$ cargo install hyperfine

If you run hyperfine with --warmup N, the hyperfine will perform the warmup N times before the actual measurement.

// warmup run
$ hyperfine --warmup 3 'dutree -d' 'dutree -d2' 'dust'
// actual run
$ hyperfine 'dutree -d' 'dutree -d2' 'dust'
hyperfine result. Image by the author

A fuzzy finder: skim

A fuzzy finder helps you to search and open files quickly. It is an interactive version of grep.

skim is a fuzzy finder in Rust. (fzf is a fuzzy finder written in the Go language, and is an excellent alternative as well.)

You can install it using Cargo.

$ cargo install skim

Please see this page for other installations.

You can search for files.

$ sk
$ file-name
File search with sk command

Or using grep to find a line in files.

sk --ansi -i -c 'grep -rI --color=always --line-number "{}" .'
Line search with sk command

sed alternative: sd

In Linux, you can use sed to perform basic text replacement.

You can install sd using Cargo.

cargo install sd

sd uses simpler syntax.

Using sd:

$ sd before after

Whereas using sed:

$ sed s/before/after/g

Replacing newlines with commas with sd:

$ sd '\n' ','

And with sed:

$ sed ':a;N;$!ba;s/\n/,/g'

sd is faster than sed.

Image from sd

top/htop alternatives: ytop and bottom

htop in Linux is an interactive process viewer. ytop and bottom are graphical process monitors.

You can install them with Cargo:

$ cargo install ytop
$ cargo install bottom

You can run bottom using btm.

The bottom in action. Image by the author

A Bonus Tip

When you use another computer, server, or system, you will be using Linux commands. It is a good idea to keep using Linux commands even if you are using Rust-powered alternatives.

I suggest creating aliases.

In my .zshrc I have the followings:

Aliases in my .zshrc. Image by the author

If you are a Powershell user:

Aliases in Powershell

Conclusion

I hope you start using these Rust-powered utility tools. You will find they are very fast and modern looking. If you know of more, please let me know!

Get full access to every story on Medium by becoming a member.

https://blog.codewithshin.com/subscribe
Rust
Rustlang
Cli
Command Line
Programming
Recommended from ReadMedium