Live data from Hacker News

Scripts I wrote that I use all the time

evanhahn.com

341–350 of 408 posts

Re: Scripts I wrote that I use all the time

#341

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"

I'm terrible about remembering shortcuts (edit a bash line in an editor? Can never remember it) but clear (CTRL-l) is one that really stuck.

That and exit (CTRL-d). A guy I used to work with just mentioned it casually and someone it just seared itself into my brain.

Re: Scripts I wrote that I use all the time

#342

Earlier quoted context omitted.

They do get to work on someone else's server, they do not get a separate account on that server. There client would be not happy to have them mess around with the environment.

By definition, it the client Alice gives contractor Mallory access to user account alice, that's worse than giving them an account called mallory. Accounts are basically free. Not having accounts; that's expensive.

They specifically mentioned service accounts. If they’re given an user account to login as, they still might have to get into and use the service account, and its environment, from there. If the whole purpose was to get into the service account, and the service account is already setup for remote debug, then the client might prefer to skip the creation of the practically useless user account.

Re: Scripts I wrote that I use all the time

#343
I use my "dc" command to reverse "cd" frequently https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9...

Ex:

    > echo $PWD
    /foo/bar/batz/abc/123

    > dc bar && echo $PWD
    /foo/bar
Useful for times when I don't want to type a long train of dot slashes(ex. cd ../../..).

Also useful when using Zoxide, and I tab complete into a directory tree path where parent directories are not in Zoxide history.

Added tab complete for speed.

Re: Scripts I wrote that I use all the time

#344

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…

What's the difference between 'source' and '.' ?

If $SHELL is /bin/sh, the source command does not exist, but '.' still works.

Re: Scripts I wrote that I use all the time

#345
post #343

I use my "dc" command to reverse "cd" frequently https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9... Ex: > echo $PWD /foo/bar/batz/abc/123 > dc bar && echo $PWD /foo/bar Useful for times when I don't want to type a long train of dot slashes(ex. cd ../../..). Also useful when using Zoxide, and I tab complete into a directory tree path where parent directories are not in Zoxide history. Added tab complete f…

That's pretty neat. Nice.

Re: Scripts I wrote that I use all the time

#346
I have a script/alias,named p, that allows me to task switch. It takes an issue and maybe an argument, and does a bunch of things if they make sense in context. It has grown over the years.

So 'p ISSUE-123' :

* creates a folder issues/ISSUE-123 for work files, containing links to a backed up folder and the project repository . The shell is cd'd to it

* The repo might get a new branch with the issue name.

* An IDE might start containing the project.

* The browsers home button brings you to a page with all kinds of relevant links:. The issue tracker, the CI, all kinds of test pages, etc...

* The open/save dialogs for every program gets a shortcut named'issue'

* A note is made in a log that allows me to do time tracking at the end if the week.

* A commit message template with the issue is created.

Re: Scripts I wrote that I use all the time

#347

Earlier quoted context omitted.

Yes, flagging mechanism on HN is evil.

It’s a blunt tool, but quite useful for posts. I read most dead posts I come across and I don’t think I ever saw one that was not obviously in violation of several guidelines. 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 fla…

Agreed, flagging for comments seems to function pretty well for the most part, and the vouch option provided a recourse for those that shouldn't have been killed.

On stories however, I think the flag system is pretty broken. I've seen so many stories that get flagged because people find them annoying (especially AI-related things) or people assume it will turn into a flame war, but it ends up burying important tech news. Even if the flags are reversed, the damage is usually done because the story fell off the front page (or further) and gets very little traction after that.

Re: Scripts I wrote that I use all the time

#348
post #266
post #262

I'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…

Slightly related but mise, a tool you can use instead of eg make, has “on enter directory” hooks that can reconfigure your system quite a bit whenever you enter the project directory in the terminal. Initially I was horrified by this idea but I have to admit it’s been quite nice to enter into a directory and everything is set up just right, also for new people joining. It has built in version management of just about…

Other similar tools:

- direnv: https://direnv.net/ simple tool and integrates with nix

- devenv: https://devenv.sh/ built on nix and is pretty slice

Re: Scripts I wrote that I use all the time

#350
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 love this kind of stuff too, but too many times over the years I've found myself in environments without some of these higher level and more niche tools (including my own dot files), or the tool ends up abandoned, and I struggle to remember how to use the basics/builtins. I've gotten a lot more conservative about adopting them because of that.
Post reply on HN