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…
Scripts I wrote that I use all the time
271–280 of 408 posts
Re: Scripts I wrote that I use all the time
#272I have a bunch, but one that I rarely see mentioned but use all the time is memo(1) ( https://github.com/aktau/dotfiles/blob/master/bin/memo ). It memoizes the command passed to it. $ memo curl https://some-expensive.com/api/call | jq . | awk '...' Manually clearing it (for example if I know the underlying data has changed: $ memo -c curl https://some-expensive.com/api/call In-pipeline memoization (includes the input…
I wonder if we have gotten to the point where we can feed an LLM our bash history and it could suggest improvements to our workflow.
Re: Scripts I wrote that I use all the time
#273The most useful script I wrote is one I call `posh`. It shorten a file path by using environment variables. Example: $ posh /home/ramrachum/Dropbox/notes.txt $DX/notes.txt Of course, it only becomes useful when you define a bunch of environment variables for the paths that you use often. I use this a lot in all of my scripts. Basically whenever any of my script prints a path, it passes it through `posh`.
I'd love to see this script. Does it use `env` and strip out things like PWD?
Re: Scripts I wrote that I use all the time
#274I have a bunch, but one that I rarely see mentioned but use all the time is memo(1) ( https://github.com/aktau/dotfiles/blob/master/bin/memo ). It memoizes the command passed to it. $ memo curl https://some-expensive.com/api/call | jq . | awk '...' Manually clearing it (for example if I know the underlying data has changed: $ memo -c curl https://some-expensive.com/api/call In-pipeline memoization (includes the input…
15 years of Linux and I learn something new all the time...
Re: Scripts I wrote that I use all the time
#275I've written on this before, but I have an extensive collection of "at" scripts. This started 25+ years ago when I dragged a PC tower running BSD to a friend's house, and their network differed from mine. So I wrote an @friend script which did a bunch of ifconfig foo. Over time that's grown to an @foo script for every project I work on, every place I frequent that has some kind of specific setup. They are prefixed wi…
I've always wanted a linux directory hook that runs some action. Say I have a scripts dir filled with 10 different shells scripts. I could easily have a readme or something to remember what they all do.
What I want is some hook in a dir that every time I cd into that dir it runs the hook. Most of the time it would be a simple 'cat usage.txt' but sometimes it maybe 'source .venv/bin/activate'.
I know I can alias the the cd and the hook together but I don't want that.
Re: Scripts I wrote that I use all the time
#276Earlier 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.
Re: Scripts I wrote that I use all the time
#277I've written on this before, but I have an extensive collection of "at" scripts. This started 25+ years ago when I dragged a PC tower running BSD to a friend's house, and their network differed from mine. So I wrote an @friend script which did a bunch of ifconfig foo. Over time that's grown to an @foo script for every project I work on, every place I frequent that has some kind of specific setup. They are prefixed wi…
I'm stealing the top comment here because you probably know what I'm asking. I've always wanted a linux directory hook that runs some action. Say I have a scripts dir filled with 10 different shells scripts. I could easily have a readme or something to remember what they all do. What I want is some hook in a dir that every time I cd into that dir it runs the hook. Most of the time it would be a simple 'cat usage.txt'…
Re: Scripts I wrote that I use all the time
#278Earlier quoted context omitted.
And the worst of it gets flagged and even dead-ed so most skip it after a bit, as I assumed would happen recently https://news.ycombinator.com/item?id=45649771
Yes, flagging mechanism on HN is evil.
OTOH I don’t like flagging stories because good ones get buried regularly. But then HN is not a great place for peaceful, nuanced discussion and these threads often descend into mindless flame wars, which would bury the stories even without flagging.
So, meh. I think flagging is a moderately good thing overall but it really lacks in subtlety.
Re: Scripts I wrote that I use all the time
#279Earlier quoted context omitted.
I'd love to see this script. Does it use `env` and strip out things like PWD?
I wrote it in a way that's too intertwined with my other shit to be shareable with people, but honestly you can copy-paste my comment to your friendly neighborhood LLM and you'll get something decent. Indeed it uses `env`.
Re: Scripts I wrote that I use all the time
#280I've written on this before, but I have an extensive collection of "at" scripts. This started 25+ years ago when I dragged a PC tower running BSD to a friend's house, and their network differed from mine. So I wrote an @friend script which did a bunch of ifconfig foo. Over time that's grown to an @foo script for every project I work on, every place I frequent that has some kind of specific setup. They are prefixed wi…
I'm stealing the top comment here because you probably know what I'm asking. I've always wanted a linux directory hook that runs some action. Say I have a scripts dir filled with 10 different shells scripts. I could easily have a readme or something to remember what they all do. What I want is some hook in a dir that every time I cd into that dir it runs the hook. Most of the time it would be a simple 'cat usage.txt'…
Its intended use case is loading environment variables (you could use this to load your virtualenv), but it works by sourcing a script — and that script can be ‘cat usage.txt.’
Great tool.
If you use Emacs (and you should!), there’s a direnv mode. Emacs also has its own way to set configuration items within a directory (directory-local variables), and is smart enough to support two files, so that there can be one file checked into source control for all members of a project and another ignored for one’s personal config.