Live data from Hacker News

Scripts I wrote that I use all the time

evanhahn.com

111–120 of 408 posts

Re: Scripts I wrote that I use all the time

#111

These are great, and I have a few matching myself. Here are some super simple ones I didn't see that I use almost every day: cl="clear" g="git" h="history" ll="ls -al" path='echo -e ${PATH//:/\\n}' lv="live-server" And for common navigation: dl="cd ~/Downloads" dt="cd ~/Desktop"

k=kubectl

Re: Scripts I wrote that I use all the time

#112
post #64
post #55

I have a bunch of little scripts and aliases I've written over the years, but none are used more than these... alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' alias ......='cd ../../../../..' alias .......='cd ../../../../../..'

I have setup a shortcut: alt+. to run cd.., it's pretty cool. I also aliased - to run cd -

but alt-. in bash is used for pasting the last argument to the previous command into the current one.

Re: Scripts I wrote that I use all the time

#113

    alias mpa='mpv --no-video'

    mpa [youtube_url]
I use this to listen to music / lectures in the terminal.

I think it needs yt-dlp installed — and reasonably up to date, since YouTube keeps breaking yt-dlp... but the updates keep fixing it :)

Re: Scripts I wrote that I use all the time

#114
post #113

alias mpa='mpv --no-video' mpa [youtube_url] I use this to listen to music / lectures in the terminal. I think it needs yt-dlp installed — and reasonably up to date, since YouTube keeps breaking yt-dlp... but the updates keep fixing it :)

On the subject of yt-dlp, I use it to get (timestamped) transcripts from YouTube, to shove into LLMs for summaries.

    ytsub() {
        yt-dlp \
            --write-sub \
            --write-auto-sub \
            --sub-lang "en.*" \
            --skip-download \
            "$1" && vtt2txt
    }

    ytsub [youtube_url]
Where vtt2txt is a python script — slightly too long to paste here — which strips out the subtitle formatting, leaving a (mostly) human readable transcript.

Re: Scripts I wrote that I use all the time

#116
post #6

This is exactly the kind of stuff I'm most interested in finding on HN. How do other developers work, and how can I get better at my work from it? What's always interesting to me is how many of these I'll see and initially think, "I don't really need that." Because I'm well aware of the effect (which I'm sure has a name - I suppose it's similar to induced demand) of "make $uncommon_task much cheaper" -> "$uncommon_ta…

I'd love to see a cost benefit analysis of the author's approach vs yours, which includes the time it took the author to create the scripts, remember/learn to use them/reference them when forgetting syntax, plus time spent migrating whenever changing systems.

Not all time is created equal. I’ll happily invest more time than I’ll ever get back in refining a script or vim config or whatever, so that later, when I’m busy and don’t have time to muck around, I can stay in the flow and not be annoyed by distractions.

Re: Scripts I wrote that I use all the time

#117
post #71

Earlier quoted context omitted.

You can apply your dotfiles to servers you SSH into rather easily. I'm not sure what your workflow is like but frameworks like zsh4humans have this built in, and there are tools like sshrc that handle it as well. Just automate the sync on SSH connection. This also applies to containers if you ssh into them.

I'm guessing you haven't worked in Someone Else's environment? The amount of shit you'll get for "applying your dotfiles" on a client machine or a production server is going to be legendary. Same with containers, please don't install random dotfiles inside them. The whole point of a container is to be predictable.

Do you have experience with these tools? Some such as sshrc only apply temporarily per session and don't persist or affect other users. I keep plain 'ssh' separate from shell functions that apply dotfiles and use each where appropriate. You can also set up temporary application yourself pretty easily.

Re: Scripts I wrote that I use all the time

#118
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…

For trash on macOS, I recommend https://github.com/ali-rantakari/trash

Does all the right things and works great.

There’s a similar tool that works well on Linux/BSDs that I’ve used for years, but I don’t have my FreeBSD desktop handy to check.

Re: Scripts I wrote that I use all the time

#119
> ocr my_image.png extracts text from an image and prints it to stdout. It only works on macOS

The Mac Shortcut at https://github.com/e-kotov/macos-shortcuts lets you select a particular area of the screen (as with Cmd-Shift-4) and copies the text out of that, allowing you to copy exactly the text you need from anywhere on your screen with one keyboard shortcut. Great for popups with unselectable text, and copying error messages from coworkers' screenshares.

Re: Scripts I wrote that I use all the time

#120
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.

Exactly! I didn’t know macOS ships JQ or the uuidgen tool. Very cool
Post reply on HN