Ask HN: Share a shell script you like
It might be something you incorporated to your terminal-based workflow. Or maybe some specific scripts that you often reuse. Or you have used it once, but it might be useful to other people. Or maybe you just have a script that is fun to use? Please share
My (not anymore) hidden intention is to gather your recommendations to build an open-source shell script registry https://spellbook.maczan.pl/ Source code is here for you if you want to self host or fork it https://github.com/jmaczan/spellbook
A script I sometimes use is a commands repeater https://registry.spellbook.maczan.pl/repeat-sh/spell.sh You can specify an interval and a flag to reset/keep the terminal's content after a script invocation
Thanks!
[+] [-] SushiHippie|2 years ago|reply
Stolen from: https://superuser.com/questions/538130/filter-in-wireshark-f...
And these functions extract a tar/zip to a temporary directory and cd into it. Useful to quickly peek into tar/zip files without littering your home/download directory. (/tmp gets cleared after a system restart for me)[+] [-] mid-kid|2 years ago|reply
Out of scripts I actually use a lot? Boring stuff like "refactor":
This one is obviously less useful for languages with namespaces, hence why --include currently only really has C and a few Assembly flavors.I wish there was a CLI "refactor" tool that supported LSP, without needing a heavy editor to do that.
[+] [-] UI_at_80x24|2 years ago|reply
I prefer that info to be in my PS1. PS1="\[\e[0;36m\[\e[m\] \[\e[0;36m\][\w]\[\e[m\]\n\t \u@\h \[\e[0;36m\]\$ \[\033[0m\]"
Double-tapping Enter before I run a command where I'll want to know the time I launched it as, solves the "when did I launch this?" question.
Example output: [~] 10:22:16 username@hostname $
[+] [-] swores|2 years ago|reply
Thanks for the timestamp function! I can't believe it never occurred to me to do something like that before, and unlike you I think I actually will be using it now and then :)
[+] [-] ray_v|2 years ago|reply
[+] [-] KolenCh|2 years ago|reply
[+] [-] saurik|2 years ago|reply
[+] [-] GhostWhisperer|2 years ago|reply
my favorite aliases
aliases are cool but in zsh there's the concept of global aliases makes equivalent to the ones i use the most are i also use starship for my prompt which gives me a lot of information about where i'm at and what's available in $PWD, but on top of that i also set the `chpwd` function to list the last five modified items[+] [-] nektro|2 years ago|reply
[+] [-] Leftium|2 years ago|reply
[+] [-] spelufo|2 years ago|reply
[+] [-] GhostWhisperer|2 years ago|reply
[+] [-] suprjami|2 years ago|reply
[+] [-] error9348|2 years ago|reply
https://developer.run/37
[+] [-] hnfong|2 years ago|reply
[+] [-] dizhn|2 years ago|reply
[+] [-] comprev|2 years ago|reply
- https://github.com/koalaman/shellcheck
[+] [-] N0YS|2 years ago|reply
https://github.com/Magnushhoie/fuz
As a nice side-effect, I no longer worry about where I store text (e.g. with Obsidian), as I know I'll find it again if it's there. It helps using memorable keywords though.
[+] [-] dyingkneepad|2 years ago|reply
Learned this with Mandriva, could never again live without it.
[+] [-] tpoacher|2 years ago|reply
[+] [-] w10-1|2 years ago|reply
The effort to document shell is also somewhat Pyrrhic. The benefit would be... more shell? A more modern shell?
Another goal might be to switch to a real language sooner. Go and Python are the obvious choices, but Swift and Java also support shebang's:
Dependencies are always tricky. swift-sh allows you to declare dependencies as comments after the import: https://github.com/mxcl/swift-sh[+] [-] frfl|2 years ago|reply
- quickly opening my personal wiki: https://github.com/francium/dotfiles/blob/master/bin/.local/...
- re-run a script when a file changes: https://github.com/francium/dotfiles/blob/master/bin/.local/...
For `while-watchdo` you, you run it like `while-watchdo "echo hi"`, then in my editor, I have a custom shortcut that does `touch .watchfile` causing the command, in this case `echo hi` to run. I prefer this to tools that retrigger commands as soon as you save _any_ file. Also works in docker containers, edit a file on host, command runs in a container.
[+] [-] LanternLight83|2 years ago|reply
[+] [-] Arcuru|2 years ago|reply
[+] [-] kazinator|2 years ago|reply
https://www.kylheku.com/cgit/basta/tree/basta.sh
[+] [-] ksherlock|2 years ago|reply
```
```
I wanted to link to a nice web page about the history of the (external) true command but google can't find anything anymore.
[+] [-] m10k|2 years ago|reply
Is it this one?
[+] [-] saurik|2 years ago|reply
[+] [-] lathiat|2 years ago|reply
[+] [-] akkartik|2 years ago|reply
[+] [-] izoow|2 years ago|reply
https://github.com/junegunn/fzf#key-bindings-for-command-lin...
[+] [-] Leftium|2 years ago|reply