sd will not “revolutionize” anything you do,
it’s just one of those things quietly in the background providing comfort
without you having to think about it.
Here’s how the project describes itself:
sd is a tool for running scripts in your script directory.
That sounds a bit vague, let me explain why I think this is so good.
You could also stop reading me and head on over to an explanation by the author of sd.
I especially liked this part:
Here’s my elevator pitch forsdis for script hoarders, who want to rage against the chaos of their~/bin. Andsdis for people who spend a lot of time combing throughctrl-r, looking for that oneliner that they never thought to make into a script, because it was too much of a hassle and who knows if they’ll ever run it again.
sd:
sdallows you to organise and run all your (oneliner) shell scripts while keeping your$PATHclean.
Usage
Let’s take a look atsd in practice.
$ sd qr --which
/home/sybrand/sd/qr~/sd.
$ sd qr --cat
#!/usr/bin/env bash
# Show a QR code of the given args
# Useful for sharing URLs and text snippets to your phone.
set -euo pipefail
echo "$@" | qrencode -o - --type=ANSI256UTF8$ sd qr 'https://github.com/ianthehenry/sd'
█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ █▄▀▀▄▄██▄ ▄█▀▀█ ▄▄▄▄▄ ████
████ █ █ ███▄█ ██▄ ▀▄▀ █ █ █ ████
████ █▄▄▄█ ██▄▀▄▀█▄ ▀ ▄▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ █ ▀▄▀▄▀ █ ▀ █▄▄▄▄▄▄▄████
████▄▄█▄ █▄█▀ ▄▄▀ ██ ▄▀ █▀▄▀▀█▀▀▄████
████▀ ▄▀ █▄▀▄▀ ▀ █ ▀ ███▀▀ ▄▀▄█▀████
████▀ ▀ █▄▄▄▄█▄▄ ▀█▄▀▀█▄█ ▀▀▀▀ ████
█████ ▄██ ▄▄ ▄ ▄▄█▄▄█ ▄▄▄▀ █ █ ████
████ ▀█ █▄█▀ █▀▀▀ █▀▀ ▄▄██▀▄▀▀█████
████ ▄█ ▀▄ ▄ ▄▄▀█▀ █▄█ ██▀█▄ ▀█▄████
████▄▄▄█▄█▄▄▀█▄█▄▄ █ ▀█ ▄▄▄ ▄▄█████
████ ▄▄▄▄▄ ██ ██▄█ ▄▀▀ █▄█ ▄███████
████ █ █ █ ▄█▀▄▄▀▄██▄▄ ▄▄▄▄█▄ ████
████ █▄▄▄█ █▀▄▀█▀▀ ▄▀▄ █▄▄▀ ▄▀ ▄ ████
████▄▄▄▄▄▄▄█▄▄▄▄▄███▄██▄▄█▄█▄████████
█████████████████████████████████████
█████████████████████████████████████Filesystem
sd is a one-to-one mapping between the arguments it takes and the filesystem.
It first drills down into your script directory like subcommands,
then passes the rest of the arguments to your script.
TODO
Kernel
One could theoretically obtain the core feature ofsd by modifying your kernel’s exec function to traverse directories and pop args as described above.
You’d then only need an alias sd=~/sd.
I do not know of any operating system that has done this.
Neither do I know if it would be practical.
Conclusion
Go! Try it out! Or don’t. You might already have a system for your scripts, it could be interesting to compare and contrast.One more thing:
sd is so conceptually simple and easy to hack on
that I rewrote it into a small
210 lines of code spread over 2 files, 1 transitive dependency (on
Rust project.
Just because I’m bad at bash and
didn’t want to forever depend on a third-party script for something this simple and important.
anyhow)