Live data from Hacker News

Scripts I wrote that I use all the time

evanhahn.com

161–170 of 408 posts

Re: Scripts I wrote that I use all the time

#161

> alphabet just prints the English alphabet in upper and lowercase. I use this surprisingly often (probably about once a month) I genuinely wonder, why would anyone want to use this, often?

For me it's when I call customer service or support on the phone, and either give them an account #, or confirm a temporary password that I have been verbally given.

Re: Scripts I wrote that I use all the time

#162

While you're creating and testing aliases, it's handy to source your ~/.zshrc whenever you edit it: alias vz="vim ~/.zshrc && . ~/.zshrc" I alias mdfind to grep my .docx files on my Mac: docgrep() { mdfind "\"$@\"" -onlyin /Users/xxxx/Notes 2> >(grep --invert-match ' \[UserQueryParser\] ' >&2) | grep -v -e '/Inactive/' | sort } I use an `anon` function to anonymize my Mac clipboard when I want to paste something to t…

ha! alias vz="vim ~/.zshrc && . ~.zshrc" is brilliant. Editing zshrc and sourcing is something I do pretty often. Never thought to alias

Re: Scripts I wrote that I use all the time

#163
post #33

> trash a.txt b.png moves `a.txt` and `b.png` to the trash. Supports macOS and Linux. The way you’re doing it trashes files sequentially, meaning you hear the trashing sound once per file and ⌘Z in the Finder will only restore the last one. You can improve that (I did it for years) but consider just using the `trash` commands which ships with macOS. Doesn’t use the Finder, so no sound and no ⌘Z, but it’s fast, offici…

I am not the author, but my bet is that he didn't know of its existence. The best part about sharing your config or knowledge is that someone will always light up your blind spots.

also possible (even though I've seen the author's response to not knowing) is that the scripts were written before native was included. at that point, the muscle memory is just there. I know I have a few scripts like that myself

Re: Scripts I wrote that I use all the time

#164

It's weird how the circle of life progresses for a developer or whatever. - When I was a fresh engineer I used a pretty vanilla shell environment - When I got a year or two of experience, I wrote tons of scripts and bash aliases and had a 1k+ line .bashrc the same as OP - Now, as a more tenured engineer (15 years of experience), I basically just want a vanilla shell with zero distractions, aliases or scripts and use…

man, i couldn't live without alias ..='cd ..' or alias ...='cd ../..'

to this day, i still get tripped up when using a shell for the first time without those as they're muscle memory now.

Re: Scripts I wrote that I use all the time

#165
post #156

Earlier quoted context omitted.

That seems to be especially true on HN. Other forums there is some of that as well, but HN it seems nearly every single comment section is like 75% (random number) pointing out faults in the posted article.

I find that endearing for two reasons: - either critique is solid and I learn something - or commenter is clueless which makes it entertaining there is very seldom a “middle”

Yea I don't particularly mind it, just an interesting thing about HN compared to many other forums.

Re: Scripts I wrote that I use all the time

#166
post #146

Earlier quoted context omitted.

I am not the author, but my bet is that he didn't know of its existence. The best part about sharing your config or knowledge is that someone will always light up your blind spots.

Or more abstractly: post anything to the internet and people will always detail how you’re wrong. Sometimes that can be useful.

This is, incidentally, codified as Cunningham's Law.

https://meta.wikimedia.org/wiki/Cunningham%27s_Law

...aaand less directly (though referenced in the wikipedia article)...

https://xkcd.com/386/

Re: Scripts I wrote that I use all the time

#167

Earlier quoted context omitted.

Atuin is new to me! https://github.com/atuinsh/atuin Discussed 4 months ago: Atuin – Magical Shell History https://news.ycombinator.com/item?id=44364186 - June 2025, 71 comments

I gave it a try a few months ago, but did not work for me. My main issue is that atuin broke my workflow with fzf (If I remember correctly, pressing ctrl + r to lookup my shell history did not work well after installing atuin).

I'm sympathetic, also a longtime fzf user here. I install it reflexively on any system I use for more than a day or two.

Re: Scripts I wrote that I use all the time

#168
post #28

Earlier quoted context omitted.

why is this interesting to you? the whole point of doing all of this is to be more efficient in the long run. of course there is an initial setup cost and learning curve after which you will hopefully feel quite efficient with your development environment. you are making it sound like it is not worth the effort because you have to potentially spend time learning "it"? i do not believe that it takes long to "learning"…

It's interesting because there's a significant chance one wastes more time tinkering around with custom scripts than saving in the long run. See https://xkcd.com/1205/ For example. The "saves 5 seconds task that I do once a month" from the blog post. Hopefully the author did not spend more than 5 minutes writing said script and maintaining it, or they're losing time in the long run.

Maybe, but

1. even if it costs more time, it could also save more annoyance which could be a benefit

2. by publishing the scripts, anyone else who comes across them can use them and save time without the initial cost. similarly, making and sharing these can encourage others to share their own scripts, some of which the author could save time with

Re: Scripts I wrote that I use all the time

#169
I have three different way to open file with vim: v: vim (or neovim, in my case) vv: search/preview and open file by filename vvv: search/preview and open file by its content

    alias v='nvim'
    alias vv='f=$(fzf --preview-window "right:50%" --preview "bat --color=always {1}"); test -n "$f" && v "$f"'
    alias vvv='f=$(rg --line-number --no-heading . | fzf -d: -n 2.. --preview-window "right:50%:+{2}" --preview "bat --color=always --highlight-line {2} {1}"); test -n "$(echo "$f" | cut -d: -f1)" && v "+$(echo "$f" | cut -d: -f2)" "$(echo "$f" | cut -d: -f1)"'
Post reply on HN