wezm.net/v1/content/technical/2019/10/useful-command-line-tools.md

370 lines
14 KiB
Markdown
Raw Normal View History

2019-10-26 03:15:56 +00:00
Inspired by [a similar post by Ben Boyter][boyter] this a list of useful
command line tools that I use. It's not a list of every tool I use. These are
tools that are new or typically not part of a standard POSIX command line
environment.
This post is a living document and will be updated over time. It should be
obvious that I have a **strong** preference for fast tools without a large
runtime dependency like Python or node.js. Most of these tools are portable
to \*BSD, Linux, macOS. Many also work on Windows. For OSes that ship up
to date software many are available via the system package repository.
2019-10-31 10:04:42 +00:00
**Last updated:** 31 Oct 2019
2019-10-27 22:23:25 +00:00
2019-10-26 03:15:56 +00:00
**About my CLI environment:** I use the [zsh] shell, [Pragmata Pro] font, and
[base16 default dark][base16] color scheme. My prompt is generated by
[promptline].
## Table of Contents
2019-10-31 10:04:42 +00:00
* [Alacritty](#alacritty) — Terminal emulator
* [alt](#alt) — Find alternate files
* [bat](#bat) — `cat` with syntax highlighting
* [bb](#bb) — System monitor
* [chars](#chars) — Unicode character search
* [dot](#dot) — Dot files manager
* [dust](#dust) — Disk usage analyser
* [eva](#eva) — Calculator
* [exa](#exa) — Replacement for `ls`
* [fd](#fd) — Replacement for `find`
* [hexyl](#hexyl) — Hex viewer
* [hyperfine](#hyperfine) — Benchmarking tool
* [jq](#jq) — `awk`/XPath for JSON
* [mdcat](#mdcat) — Render Markdown in the terminal
* [pass](#pass) — Password manager
* [Podman](#podman) — Docker alternative
* [Restic](#restic) — Encrypted backup tool
* [ripgrep](#ripgrep) — Fast, intelligent `grep`
* [shotgun](#shotgun) — Take screenshots
* [skim](#skim) — Fuzzy finder
* [slop](#slop) — Graphical region selection
* [Syncthing](#syncthing) — Decentralised file synchronisation
* [tig](#tig) — TUI for `git`
* [titlecase](#titlecase) — Convert text to title case
* [Universal Ctags](#ctags) — Maintained `ctags` fork
* [watchexec](#watchexec) — Run commands in response to file system changes
* [z](#z) — Jump to directories
* [zola](#zola) — Static site compiler
* [Changelog](#changelog) — The changelog for this page
2019-10-26 03:15:56 +00:00
<a name="alacritty"></a>
### Alacritty ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
Alacritty is fast terminal emulator. Whilst not strictly a command line tool, it
does host everything I do in the command line. It is the terminal emulator in use
in all the screenshots on this page.
<a class="action-button action-button-ghost" href="https://github.com/jwilm/alacritty">Homepage</a>
<a name="alt"></a>
### alt ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`alt` is a tool for finding the alternate to a file. E.g. the header for an
2019-10-27 06:10:57 +00:00
implementation or the test for an implementation. [I use it paired with Neovim][nvim-alt]
2019-10-26 03:15:56 +00:00
to easily toggle between tests and implementation.
$ alt app/models/page.rb
spec/models/page_spec.rb
<a class="action-button action-button-ghost" href="https://github.com/uptech/alt">Homepage</a>
<a name="bat"></a>
### bat ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`bat` is an alternative to the common (mis)use of `cat` to print a file to the
terminal. It supports syntax highlighting and git integration.
![bat screenshot](/images/cli/bat.png)
<a class="action-button action-button-ghost" href="https://github.com/sharkdp/bat">Homepage</a>
2019-10-31 10:04:42 +00:00
<a name="bb"></a>
### bb ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
2019-10-31 21:01:06 +00:00
`bb` is system monitor like `top`. It shows overall CPU and memory usage as well as
2019-10-31 10:04:42 +00:00
detailed information per process.
![bb screenshot](/images/cli/bb.png)
<a class="action-button action-button-ghost" href="https://github.com/epilys/bb">Homepage</a>
2019-10-26 03:15:56 +00:00
<a name="chars"></a>
### chars ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`chars` shows information about Unicode characters matching a search term.
![chars screenshot](/images/cli/chars.png)
<a class="action-button action-button-ghost" href="https://github.com/antifuchs/chars">Homepage</a>
<a name="dot"></a>
### dot ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`dot` is a dotfiles manager. It maintains a set of symlinks according to a mappings file.
I use it to manage [my dotfiles][dotfiles].
![dot screenshot](/images/cli/dot.png)
<a class="action-button action-button-ghost" href="https://github.com/ubnt-intrepid/dot">Homepage</a>
<a name="dust"></a>
### dust ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`dust` is an alternative `du -sh`. It calculates the size of a directory tree, printing
a summary of the largest items.
![dust screenshot](/images/cli/dust.png)
<a class="action-button action-button-ghost" href="https://github.com/bootandy/dust">Homepage</a>
<a name="exa"></a>
### exa ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`exa` is a replacement for `ls` with sensible defaults and added features like a
tree view, git integration, and optional icons. I have `ls` aliased to `exa` in
my shell.
![exa screenshot](/images/cli/exa.png)
<a class="action-button action-button-ghost" href="https://the.exa.website/">Homepage</a>
<a name="eva"></a>
### eva ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`eva` is a command line calculator similar to `bc`, with syntax highlighting
and persistent history.
![eva screenshot](/images/cli/eva.png)
<a class="action-button action-button-ghost" href="https://github.com/NerdyPepper/eva">Homepage</a>
<a name="fd"></a>
### fd ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`fd` is an alternative to `find` and has a more user friendly command line interface
and respects ignore files, like `.gitignore`. The combination of its speed and ignore
file support make it excellent for searching for files in git repositories.
![fd screenshot](/images/cli/fd.png)
<a class="action-button action-button-ghost" href="https://github.com/sharkdp/fd">Homepage</a>
<a name="hexyl"></a>
### hexyl ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`hexyl` is a hex viewer that uses Unicode characters and colour to make the output more
readable.
![hexyl screenshot](/images/cli/hexyl.png)
<a class="action-button action-button-ghost" href="https://github.com/sharkdp/hexyl">Homepage</a>
2019-10-27 22:19:55 +00:00
<a name="hyperfine"></a>
### hyperfine ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`hyperfine` command line benchmarking tool. It allows you to benchmark commands
with warmup and statistical analysis.
![hyperfine screenshot](/images/cli/hyperfine.png)
<a class="action-button action-button-ghost" href="https://github.com/sharkdp/hyperfine">Homepage</a>
2019-10-26 03:15:56 +00:00
<a name="jq"></a>
2019-10-26 22:18:36 +00:00
### jq ![Language: C](https://img.shields.io/badge/language-C-%23444444)
2019-10-26 03:15:56 +00:00
`jq` is kind of like `awk` for JSON. It lets you transform and extract information from JSON
documents.
![jq screenshot](/images/cli/jq.png)
<a class="action-button action-button-ghost" href="https://stedolan.github.io/jq/">Homepage</a>
<a name="mdcat"></a>
### mdcat ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`mdcat` renders Markdown files in the terminal. In supported terminals (not
Alacritty) links are clickable (without the url being visible like in a web
browser) and images are rendered.
![mdcat screenshot](/images/cli/mdcat.png)
<a class="action-button action-button-ghost" href="https://github.com/lunaryorn/mdcat">Homepage</a>
<a name="pass"></a>
### pass ![Language: sh](https://img.shields.io/badge/language-sh-%2389e051)
`pass` is a password manager that uses GPG to store the passwords. I use it with the
[passff] Firefox extension and [Pass for iOS] on my phone.
![pass screenshot](/images/cli/pass.png)
2019-10-28 10:48:29 +00:00
<a class="action-button action-button-ghost" href="https://www.passwordstore.org/">Homepage</a>
2019-10-26 03:15:56 +00:00
<a name="podman"></a>
### Podman ![Language: Go](https://img.shields.io/badge/language-Go-%2300ADD8)
`podman` is an alternative to Docker that does not require a daemon. Containers are run as
the user running Podman so files written into the host don't end up owned by root. The CLI
is largely compatible with the `docker` CLI.
![podman screenshot](/images/cli/podman.png)
<a class="action-button action-button-ghost" href="https://podman.io/">Homepage</a>
<a name="restic"></a>
### Restic ![Language: Go](https://img.shields.io/badge/language-Go-%2300ADD8)
`restic` is a backup tool that performs client side encryption, de-duplication and
supports a variety of local and remote storage backends.
<a class="action-button action-button-ghost" href="https://restic.net/">Homepage</a>
<a name="ripgrep"></a>
### ripgrep ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
ripgrep (`rg`) recursively searches file trees for content in files matching a
regular expression. It's extremely fast, and respects ignore files and binary
files by default.
![ripgrep screenshot](/images/cli/ripgrep.png)
<a class="action-button action-button-ghost" href="https://github.com/BurntSushi/ripgrep">Homepage</a>
<a name="shotgun"></a>
### shotgun ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`shotgun` is a tool for taking screenshots on X.org based environments.
All the screenshots in this post were taken with it. It pairs well with
`slop`.
$ shotgun $(slop -c 0,0,0,0.75 -l -f "-i %i -g %g") eva.png
<a class="action-button action-button-ghost" href="https://github.com/neXromancers/shotgun">Homepage</a>
<a name="skim"></a>
### skim ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`skim` is a fuzzy finder. It can be used to fuzzy match input fed to it. I use it
2019-10-27 06:10:57 +00:00
with [Neovim] and zsh for fuzzy matching file names.
2019-10-26 03:15:56 +00:00
![skim screenshot](/images/cli/skim.png)
<a class="action-button action-button-ghost" href="https://github.com/lotabout/skim">Homepage</a>
<a name="slop"></a>
### slop ![Language: C++](https://img.shields.io/badge/language-C%2B%2B-%23f34b7d)
`slop` (Select Operation) presents a UI to select a region of the screen or a
window and prints the region to stdout. Works well with `shotgun`.
$ slop -c 0,0,0,0.75 -l -f "-i %i -g %g"
-i 8389044 -g 1464x1008+291+818
<a class="action-button action-button-ghost" href="https://github.com/naelstrof/slop">Homepage</a>
<a name="syncthing"></a>
### Syncthing ![Language: Go](https://img.shields.io/badge/language-Go-%2300ADD8)
Syncthing is a decentralised file synchronisation tool. Like Dropbox but self
hosted and without the need for a central third-party file store.
<a class="action-button action-button-ghost" href="https://syncthing.net/">Homepage</a>
<a name="tig"></a>
### tig ![Language: C](https://img.shields.io/badge/language-C-%23444444)
`tig` is a ncurses TUI for git. It's great for reviewing and staging changes, viewing
history and diffs.
![tig screenshot](/images/cli/tig.png)
<a class="action-button action-button-ghost" href="https://jonas.github.io/tig/">Homepage</a>
<a name="titlecase"></a>
### titlecase ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`titlecase` is a little tool I wrote to format text using a [title case format
2019-10-27 22:19:55 +00:00
described by John Gruber][df-titlecase]. It correctly handles punctuation, and words like
2019-10-26 03:15:56 +00:00
iPhone. I use it to obtain consistent titles on all my blog posts.
$ echo 'an illustrated guide to useful command line tools' | titlecase
An Illustrated Guide to Useful Command Line Tools
2019-10-27 06:10:57 +00:00
I typically use it from within [Neovim] where selected text is piped through it in-place.
2019-10-26 03:15:56 +00:00
This is done by creating a visual selection and then typing: `:!titlecase`.
<a class="action-button action-button-ghost" href="https://github.com/wezm/titlecase">Homepage</a>
<a name="ctags"></a>
### Universal Ctags ![Language: C](https://img.shields.io/badge/language-C-%23444444)
Universal Ctags is a fork of exuberant ctags that is actively maintained.
`ctags` is used to generate a `tags` file that `vim` and other tools can use to
navigate to the definition of symbols in files.
$ ctags --recurse src
<a class="action-button action-button-ghost" href="http://ctags.io/">Homepage</a>
<a name="watchexec"></a>
### watchexec ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
2019-10-27 03:46:44 +00:00
`watchexec` is a file and directory watcher that can run commands in response to
file-system changes. Handy for auto running tests or restarting a development
2019-10-26 03:15:56 +00:00
web server when source files change.
# run command on file change
$ watchexec -w content cobalt build
# kill and restart server on file change
$ watchexec -w src -s SIGINT -r 'cargo run'
<a class="action-button action-button-ghost" href="https://github.com/watchexec/watchexec">Homepage</a>
<a name="z"></a>
### z ![Language: sh](https://img.shields.io/badge/language-sh-%2389e051)
`z` tracks your most used directories and allows you to jump to them with a
partial name.
![z screenshot](/images/cli/z.png)
<a class="action-button action-button-ghost" href="https://github.com/rupa/z">Homepage</a>
<a name="zola"></a>
### zola ![Language: Rust](https://img.shields.io/badge/language-rust-%23dea584)
`zola` is a full-featured very fast static site compiler.
![zola screenshot](/images/cli/zola.png)
<a class="action-button action-button-ghost" href="https://www.getzola.org/">Homepage</a>
2019-10-27 22:23:25 +00:00
<a name="changelog"></a>
## Changelog
2019-10-31 10:04:42 +00:00
* 31 Oct 2019 -- Add `bb`, and brief descriptions to the table of contents
2019-10-27 22:23:25 +00:00
* 28 Oct 2019 -- Add `hyperfine`
## Comments
* <img src="/images/lobsters.png" alt="" width="16" class="lobsters"> [Comments on Lobsters](https://lobste.rs/s/pven1z/illustrated_guide_some_useful_command)
* [Comments on Hacker News](https://news.ycombinator.com/item?id=21363121)
2019-10-26 03:15:56 +00:00
<div class="seperator"><hr class="left"><hr class="right"></div>
Previous Post: [What I Learnt Building a Lobsters TUI in Rust](/technical/2019/04/lobsters-tui/)
<!-- Next Post: -->
[boyter]: https://boyter.org/posts/my-list-of-useful-command-line-tools/
[dotfiles]: https://github.com/wezm/dotfiles
[df-titlecase]: https://daringfireball.net/2008/05/title_case
[base16]: https://github.com/chriskempson/base16
[Pragmata Pro]: https://www.fsd.it/shop/fonts/pragmatapro/
[promptline]: https://github.com/edkolev/promptline.vim
[zsh]: https://www.zsh.org/
[passff]: https://github.com/passff/passff
[Pass for iOS]: https://github.com/mssun/passforios
2019-10-27 06:10:57 +00:00
[nvim-alt]: https://github.com/wezm/dotfiles/blob/ad7863bcf10873c386d9ff97e4a9edaa725a15f0/vimrc#L525-L536
[Neovim]: https://neovim.io/