Useful CLI Tools
This is just a collection of CLI tools that I find particularly useful. They’re usually not part of a standard Linux distribution (and certainly not POSIX), and even though I value and appreciate being able to log in to any machine and just start working, I also appreciate being able to use more specialized tools in some environments such as the laptop I spend about 7 hours a day working on.
xsv is a stupidly fast and easy way to work with CSV files in the CLI.
# Find 10 most expensive products and output data as a table xsv sort -Rs 'price' < products.csv | xsv slice -n 10 | xsv table # Get stats about data, such as min/max, cardinality, etc. xsv stats < products.csv
jq is basically
sed for JSON. It can be
used to transform JSON or merely search it.
# Find i3's primary output i3-msg -t get_outputs | jq 'map(select(.primary))' # Get names of all dependencies in an NPM project jq -r -M '.devDependencies,.dependencies | to_entries | "\(.key)"' < packages.json # Prettify JSON in clipboard xclip -o -selection clipboard | jq '.' | xclip -i -selection clipboard
rg (aka. ripgrep) is another one of
BurntSushi’s brilliant tools. It’s a replacement for
grep and it’s
ridiculously fast. Since it’s a
grep replacement, there is no reason to post
a bunch of examples so instead here is an article by BurntSushi himself about
rg is so insanely fast.
fzf is a fuzzy finder that makes
live-searching through line-data a breeze. Where
rg is great for streams,
fzf excels when it comes to interactive searches. They can even be used
together for file searching (see examples below).
# Live search through files in the current dir and below and open it in vi vi $(rg --files | fzf) # Live search through git branches and check out the selected one # also display it a bit more sexily git checkout $(git ls-branches | fzf --height=30 --layout=reverse)
The above examples are purely illustrative and there are better and more
elegant ways go about them, see the README for
fzf for details about that.
Another runner-up for this position is
which does essentially the same but in a more simplistic way. It doesn’t quite
have the same ways of integrating with (Neo-)Vim and other tools but if you
don’t need that,
peco may be worth looking into.