What interesting command line tools do you use?
source link: https://lobste.rs/s/yfgwjr/what_interesting_command_line_tools_do
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What command-line tools do you use? Does anybody use one of the smart cd replacements, like z or zoxide or fasd? Do people use fzf at the CLI?
One that I use is a bit is funky. It just lets you define shell functions and aliases that are path-specific and live in a .funky
file.
I have new-post
in my blogs directory and one to call sox in the repo for my podcast.
Edit: This is fantastic. So many new tools to play with!
-
I’ve been using some sort of Unix since the mid 1990’s, so 25+ years.
Something that I’ve learned that works for me (YMMV) is that I tend to only use “standard” tools. I use a Bourne-compatible shell, good ole
cd
, etc. I prefer tools that have very little customizability, and for tools that can be customized I try to keep them as close to their default state as possible.The reason is that if I get too embedded in my heavily customized environment, as soon as I change machines or something gets slightly out of whack, I am useless.
I did recently by a commercial UNIX workstation^H^H^H^HMacbook, so I have started using a “modern” graphical text editor (the only other graphical text editor I ever used was
sam
), but even then I still do everything via the command line. TextMate on the Mac has excellent command-line integration (I’ve never, not once, opened a file in TextMate using theFile
menu; it’s always by typingmate
on the command line or viarmate
on a remote machine).So, I guess to answer your question: TextMate on the Mac. Pretty good command-line tooling. :)
-
I get what you are saying. It’s really easy to start customizing things and end up in very
unique
place. I have had the experience before of my fingers knowing a tool that I didn’t have installed and it can be very frustrating.That is why I am interested in this question though. Surely there are new tools that are worthy of joining the canon of ’Standard Tools`. I use ZSH and I think it is a canonical shell now. nushell or fishshell - not yet.
-
-
This is part of the problem with PowerShell beyond v5.1. It doesn’t exist without you enforcing it’s there somehow, so you still fall back to writing code for what you know will be there versus what’s better (similar things happen with Python and Bash).
-
-
-
-
-
For jq: did you heard about fx? https://fx.wtf
-
First I’ve heard of it. Looks neat!
-
-
-
Find lots of tools I have in my
~/bin
here: https://leahneukirchen.org/dotfiles/tools.htmlInteresting is, maybe:
- My “smart cd”, zz.
- Tiny printer driver cupless
- Tools for dealing with patches: diffed, unpatch
- Tools for extracting data: emails, urls
- Date nerdery: fdate, sdate, tdate
And lots of more goodies in my .zshrc.
-
These date tools are hilarious. Do you actually have use for the days since the french revolution? Is that what it does?
-
my favorite date tool: https://linux.die.net/man/1/ddate. It’s a shame it was removed from coreutils.
$ ddate Today is Boomtime, the 51st day of Confusion in the YOLD 3187
-
-
rclone - you could call it a modern rsync or scp.
It seems to be well known in some circles and relatively unknown in others so I figured I’d post it since it’s a great tool with responsive developers. It’s an rsync-like tool that supports many other backends besides rsync or ssh. What I like about it is how highly configurable it is, especially w.r.t. the controls over parallelism and how much more performant over rsync it is in situations where you have many tiny files.
-
Strongly seconded. rclone is rsync for cloud storage services. S3. Dropbox. Box. Google Drive. Tons more.
-
-
I use delta for viewing git diff output. Since I started that, I find myself reaching for GUI diff viewers much less frequently, which I like because I’ve never met a git gui that I find generally usable.
-
Vimdiff works pretty well for that use case if you’re from that church.
-
-
I only replaced very few of the standard command line tools. I tried to use replacements for cat, du and df but even those are annoying for me because I cannot use them the way I want to. I ended up using them as separate commands. One thing I like to use though is a history search replacement like mcfly
-
That looks nice, but I’ll throw in a vote for
set -o vi
as a great built-in solution to this problem which I use hundreds of times a day.Just pressing
<esc>
gives you normal vim/<your search term>
to search history. Then pressingn
goes to next match. That plus normaljk
scrolling through your most recent history items is a great solution. -
This looks very cool! Thanks for sharing.
-
-
This is more of a console based program than a CLI, but VisiData is an essential part of my workflow when dealing with structural data like CSVs. So much more convenient than using a spreadsheet like Excel and very effecient.
-
I’ve never seen VisiData before - it’s amazing! Thank you!
-
-
I use tmux a lot. I like tmux’s splits and windows and sessions, but the main reason I use it is for keyboard text selection and scrolling. I wrote a little about this here, with a demo of what it looks like: tmux lets you select and copy text with your keyboard. I don’t really remember what life was like without it.
I don’t really get the appeal of smart cd, but I have persistent tmux sessions set up for all the projects I work on, so switching directories is usually just switching my tmux session.
I wrote a little thing to hook up
fzf
to my shell completion. I have different triggers, like.f
for “select file” or.c
for “select commit,” and when I type.c<TAB>
I get a little fzf popup that lets me select a commit and insert it. I know you can just enable fzf integration with shell completion globally, but this has a few advantages:- it’s much, much, much faster than shell autocomplete (especially for selecting dirty git files)
- it’s deterministic: when I activate completion, I know exactly what choices I’m going to get – I am not at the mercy of whatever shell autocomplete decides I want to do
- I can add new triggers without having to modify a program’s shell completion (if you have not edited these scripts, they are… truly arcane), and I don’t have to worry about missing completion files for random programs.
And I can still use the default shell completion as much as I want; this just adds another option. I did this for years with global shell aliases, which have a lot of problems, but a few months ago I dove in and figured out how to hook it into regular tab-completion. It’s a little complicated, but it works great.
I really like
delta
; the goto-next-file-header thing is a brilliant hack. But I had to do a lot of work to get output that I liked.Having
nix
installed provides a cool super-power that I use a lot: temporary installation of a program. If I heard of something and want to try it out, I can runnix-shell -p fd
(for example) and play around with it. And then it “disappears” as soon as I close that shell, so I don’t have to remember to uninstall it. Lowers the barrier of trying random stuff out.I made a hacky thing to organize all of the scripts in my
~/bin
into a single hierarchical command that’s defined by its directory structure, and that automatically parses bash comments to display help lines in autocomplete. (The ability to easily add new subcommands makesnix
’s CLI a lot more palatable…)ngrok
is a really nice niche tool if you want to show your local test server to someone else (I’ve used it for sharing blog drafts, for example). There’s a paid version, mostly to combat spam, I think, but the free version is sufficient for anything I would ever do, and it doesn’t require an account or anything.terminal-notifier
is nice if you’re on a Mac… often I’ll run some long command,ctrl-z
, thenfg ; terminal-notifier -message "done $?"
. I actually have an alias for that because I do it often enough.A little different than the rest, but I use iTerm’s “Hotkey Window” almost exclusively. I’m often tabbing between a web browser and a text editor, and keeping my terminal window out of the ⌘Tab history means I never switch to it by accident because I just happened to run
git status
.I have more, but I think that’s enough for now…
-
I’m in a very similar boat regarding persistent tmux sessions, I find this to be an excellent way to maintain structured environments. I just have some simple scripts to set up a session, or attach to it if it already exists.
I love shell completion for the things where it works, but it’s frustrating when it doesn’t. Your
.c
fzf commit shortcut sounds like something I could really use, for the reasons you state: I far prefer to be explicit about what I’m looking for, so having control over exactly what I’m completing would be perfect. Looking forward to playing with it, thanks!
-
There are a few that seem to have stuck in my rotation:
-
entr: Runs an arbitrary command when a file changes, I have found this super helpful for running builds or post processing steps on files I am editing.
-
pandoc: Converts to and from many file formats. I find all sorts of uses for this tool even unblessed ones, but I primarily use it to covert from and to markdown, which allows me to compose in my preferred mode, vim+markdown. As an example I recently used it to add content to Confluence, which bizarrely only support importing Word documents. So I compose in markdown, convert to Word with Pandoc, and finally import into Confluence.
-
- watch: could always be replaced with a Bash loop, but still super handy
-
I always do the shell loop because I’ve never managed to actually learn how to use any of the fancy tools, so I just do loops with sleeps
-
While I have not sat down and used it myself yet, I’ve had my eye on https://github.com/kovetskiy/mark for a while and it may be relevant to your interests.
-
-
-
Just looks cool! it is similar to Earthly, but more for local dev rather than CI. Very cool.
-
If you like Just, you’ll love Toast!
-
We use Toast at work quite heavily. It’s been great!
-
-
-
-
Do people use fzf at the CLI?
Not by typing
fzf
but I started using its zsh bindings so it’s acting as myctrl-R
(history search) and I’ve been getting into the habit of using itsalt-C
instead of typingcd
. Thectrl-T
behaviour can be useful, but zsh’s menu completion is usually good enough that I don’t need it. Overall I love the fzf shell bindings.Other fun tools I use are
fd
, thefind
replacement, andk9s
for interacting with Kubernetes clusters. -
chezmoi gives me the same CLI environment (shell aliases, editor configs, etc.) across all the machines I use, including work, home, laptops, desktops, and temporary VMs and containers.
Disclaimer: I’m the author of chezmoi, but it’s popular and a lot of people have written about it.
-
-
I work with Git repos, but strictly through Mercurial + hggit. Templates + revsets are the best.
-
go
file1 file2 … is a little wrapper to open multiple files/dirs with xdg-open. I’ll probably rename this script if I ever have to install Golang. -
h
myprogram tries, in order, to open the man page, or runmycommand --help | less
flag, or withmycommand -h | less
. Basically “I want to read your help page, dammit” with a side order of “in a pager, please, don’t barf it straight into the terminal”. -
addkernel
installs the active Conda environment as a one of my user’s IPython/Jupyter kernels. This makes it visible from any Jupyter installation, specifically my main one. This, in turn, lets me maintain one virtualenv with a Jupyter installation + extensions, instead of one Jupyter installation per {conda,virtual}env.
-
h
! What a great idea, I’m doing that! Actually, I might call it;h
since I type this often by accident anyway, as a vim user who maps;
to:
-
-
Linux only?
-
Not at all. It wouldn’t let me submit unless I added a second tag, so I picked Linux.
-
In that case, I maintain my own Windows based shell and tools so I can incorporate newer workflows than CMD. A lot of this has been scouting out good ideas to incorporate.
- Although
z
is included,$CDPATH
/%YORICDPATH%
works better for me. These define a fixed search path, so you can build up muscle memory of where navigations go, which seems more usable than a heuristic match that can be wrong. - I’m not familiar with
funky
, but did add something likedirenv
which enables individual directories to contain scripts that modify the environment. This is nice to allow things like git repos to define state for their own environment; I use this so when entering git repos the prompt changes to indicate the current branch. - One early thing that motivated me was building a better directory enumerator for interactive use . I’m surprised these aren’t more common given how much users need to enumerate directories and how limited things like
ls
orls -l
really are. There’s no hard-and-fast rule that says an enumerator can only display information from the file system as opposed to file contents either. - Another thing that’s not spoken about enough is the line between a shell and a debugger doesn’t need to be rigid. I’ve built many cases now where the shell launches a child and debugs it to give the user more information about failures (eg. missing DLLs) or to let the user specify invasive changes (eg. override reported OS version.)
- Although
-
-
-
There are some excellent upgrades I’m embarrassed to say I only learned about recently. Perils of working in a Microsoft environment so long, I suppose.
-
rg
ripgrep instead of grep, way faster and respects .gitignore -
fd
instead of find. No need to typefind -iname "*foo*"
all the time, justfd foo
-
et
Eternal Terminal instead of ssh, to keep my session live through reconnects
And I’ve been experimenting with some newfangled toys tools as well
- zsh + powerlevel10k for an extremely fast prompt with doodads
- zsh + fzf for fuzzy history searching
- fish for incredible ergonomics: autocomplete, advanced syntax highlighting, multiline command editing
- fish + tide instead of powerlevel10k
- fish + fzf, same reason as zsh
- bat instead of cat for pretty colors and line #s
- poetry for managing Python builds in a declarative way that I’m used to from Nix
- spacemacs as a drop-in replacement for vim. the syntax highlighting is way better
Most of these upgrades boil down to either ‘go fast’ or ‘more intelligent use of color’.
-
et Eternal Terminal instead of ssh, to keep my session live through reconnects
Wait, are you Jason Gauci? I heard of this through him. He has an excellent podcast besides making that.
-
-
weather(){ CITY=${1:-auburn_wa} curl “http://wttr.in/$CITY” } more of a script than a tool
-
Some cli tools I frequently reach for are ripgrep, awk, jq (and its YAML wrapper: yq), plantuml.
I often don’t invoke them directly, however, but through a mode or function in my IDE (Emacs).
projectile
helps me run ripgrep in a project, for example, andplantuml-mode
invokes plantuml for me on relevant files.I live almost exclusively in Emacs, using Eshell when I work the cli. (Unless I need some ncurses app, like
mtr
.) The nice thing about this is I can take my entire IDE with me to remote machines, through the magic of TRAMP. Eshell also abstracts away the differences on hosts, so I mostly don’t have to care whether the underlying shell is bash or zsh. -
I wrote two for myself:
sandwatch records run times for tasks and averages past runtimes to predict how long this task will take (in sandwich units, five minutes).
bloohm shows me the status of multiple tasks in such a way that I can take a break and don’t have to stare at the screen waiting for success.
-
I cannot live without hstr any more: https://github.com/dvorka/hstr
-
I guess I’m pretty boring. This is what I spend 99.9% of my day in (on HardenedBSD):
- sakura (okay, not a command-line tool. a terminal emulator, but it’s what I use to get to the command line)
- weechat
- neomutt
Except for using a web browser, this is what I spend my day in. Boring, but efficient.
-
I’ve accumulated a bunch of junk scripts in my bin directory, most of it is really not used at all (I should clean that up..). Most of it, except git-remote-httpsify which I use all the time. It’s a script that configures a GitHub remote to use HTTPS for pull, SSH for push. Also I use patch2fbsd sometimes to convert git diffs to the kind of patch FreeBSD Ports expects (with
.orig
on the---
line, nothing on the+++
line instead ofa
/b
/i
/w
directory prefixes.)As for the bigger tools, rg, fd, fzy, jq, tig, ncdu, dog, orpie… and still
tree
(this one) for ls-ing via these aliases. Probably should switch to exa.smart cd replacements, like z or zoxide or fasd?
Nah.. zsh does everything I want already with
cdpath=(~/my/project/dirs)
andsetopt auto_pushd pushd_ignore_dups auto_cd
andalias p=popd
. -
Do people use fzf at the CLI?
alias gco='git checkout $(git branch | grep -v $(git rev-parse --abbrev-ref HEAD) | fzf)'
-
I also fear an overly custom environment, but I’ve come to like rg (aka ripgrep) a lot. I used to do a lot of find -exec fgrep but rg is many fewer keystrokes and marginally faster to execute.
-
Daily:
- z (better cd)
- jq (json data munging)
- delta (diff)
- pandoc (pdf, docx generation)
- tokei, ssc (sloc)
- tmux (terminal multiplexer)
- pv (progress bar)
- shuf (reservoir sampling)
- fzf and ag (only within vim)
Alias:
$ type open open is aliased to `xdg-open'
Occasionally:
- ncdu, diskonaut (disk usage)
- pup (like jq, but for html)
- ranger, nnn (file browser)
- fd (line find)
- esbulk, solrbulk, esdump, solrdump (indexing and index export tools)
- git-cal (git calendar view)
- clinker (mass link checker)
- tcptrack, speedometer, iftop, bmon (net monitoring)
-
I use tldr all the time. While reading the docs is fine, it is really nifty to quickly know how to use tools like ffmpeg which I only whip out every once in a while.
-
Shameless plug: I do a lot of work with binary formats and retro computing. To help with this, I wrote a small command-line calculator utility called xc. Allows decimal and hexidecimal input, always outputs as both, and allows for easy calculations using convenient infix notation.
-
I use Sublime Text as my
$EDITOR
and go-to editor using thesubl
command.Fork also has a command line helper to open and commit to repositories from the command line.
I don’t use any
cd
replacement, since I use Fish, where you only have to type the name of the directory you want to enter. The only caveat is that you need to add a slash at the end, but the tab completion does that for you. -
Not sure how interesting but I built gitupdate to solve automating commits on certain things where commit message does not matter. Like docs or wikis. It takes file names changed as commit message. I also like to use it on feature branches sometimes too as I like to squash commits with an actual meaningful commit on merge. Saves a bit of time.
-
I’ve been using
massren
[0] for a long time. It lets you rename all the files in CWD with$EDITOR
.-
vidir
, which comes with moreutils, also lets you do exactly this.-
IIRC, moreutils also has qmv and qcp. Great tools.
-
-
-
I use rg for code searching, my shell itself is fish, $EDITOR is kakoune, and I use pv and ncat a lot.
-
cointop, gotop, hstr, youtube-dl, topgrade, glances
-
I have a few nice addons on my personal laptop, but since I’m too lazy to install all of that on all other systems I typically just use the standard tools most of the time. So even if I’m a Emacs person I use vi when in a new FreeBSD jail, and so forth.
Some nice tools I use are:
- Emacs (magit is awesome, mu4e is teriffic, my config has been pretty stale…stable the last decade or so)
- ripgrep
- bat (cat replacement)
- neovim (much nicer out of the box than vi)
…but all of these are just nice bonuses. sed, grep, vi are forever.
-
-
I like the idea of broot, but it glitched out between the UI and
rm
and I wound up blowing away a lot of files by accident.
-
-
This isn’t a great tool (I wrote it) but it is, I believe, a great concept.
rerun2 waits for filesystem events in or below the current directory, and re-runs a given command:
rerun [OPTIONS] COMMAND
eg.
rerun --clear make test
This is handy, for example, if you have your editor in one window, and a terminal running rerun, which is running your tests, in another. Every time you hit ‘save’ in your editor, the tests automatically re-run to display the updated test results, without you having to mess about with window focus or command line history. (
--clear
clears the terminal before each test re-run)This pattern turns out to be remarkably flexible. It’s useful if you’re editing any sort of document which is rendered to some visible results. e.g. while editing markdown in your favorite editor, see an auto-updating HTML rendering of it in another window.
This is better than a “MarkdownEditor” app, that bundles together an editor and a preview pane in a single GUI app, because you aren’t tied to a particular editor or markdown renderer - you can wire together your favorite ones at runtime. And you can use the same principle on RestructuredText instead of markdown, or any other markup language.
Another example I enjoy using it with is editing DOT code to see Graphviz renders. Once I got accustomed to it, many of the things I do for work end up being susceptible to this pattern. As a result, I probably end up spending 8 hours a day looking at the output of my humble “rerun” script.
-
2 esoteric command line tools I like,
vimdiff is a greatly enhanced version of diff… with colors! it is infinitely helpful for comparing files in the terminal.
I also like lsof for checking network sockets, it isn’t as widely used as ss or netstat, but it is a potent way to monitoring network sockets in *nix
lsof -i
Also, not an esoteric command line tool, but I use this command all the time because it’s such a great find hack
find . | grep "xyz"
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK