Live data from Hacker News

Ask HN: Small scripts, hacks and automations you're proud of?

news.ycombinator.com

331–340 of 340 posts

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#331
I navigate across my favorites directories at light speed, using this simple alias which uses fzf.

alias f='files=$(cat ~/.fzfdirs | fzf) && cd "${files}"'

I type f and it fuzzy find the directory that I have added to the ~/.fzfdirs file and cd into it.

If I want to add a dir, I append the directory into the file or `pwd >> ~/.fzfdirs` inside the wanted directory.

I find it simple and efficient. I gives me an amazing boost of productivity for moving across directories.

With 3-4 key stokes I get inside any common directory on my box.

fzf is so amazing.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#332
I switched back to debian-based distro from arch linux and I'm frustrated that I need to go to the nerd fonts repo just to download some fonts. So I made a script for it: https://gist.github.com/DatSudo/e42d68a78d096a3b7116e67d7c15...

I can easily get Iosevka Nerd Font just by running the command

  install_nerd.sh Iosevka

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#333
post #84

I wrote one where when the tic mark and top row number one were pressed together, it sends a single left mouse click tic mark and top row number 2 sends a double mouse click. It helps reduce strain on my right hand mouse clicking finger.

does this use xdotool? can you share

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#334
post #333
post #84

I wrote one where when the tic mark and top row number one were pressed together, it sends a single left mouse click tic mark and top row number 2 sends a double mouse click. It helps reduce strain on my right hand mouse clicking finger.

does this use xdotool? can you share

maybe you use xbindkeys?

    "xdotool mousedown 1"
      b:49+1
    "xdotool mouseup 1"
      b:49+Release+1

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#335
post #334
post #333

Earlier quoted context omitted.

does this use xdotool? can you share

maybe you use xbindkeys? "xdotool mousedown 1" b:49+1 "xdotool mouseup 1" b:49+Release+1

hmm unfortunately, the above does not work. I was able to get basic clicking working like this:

    cat .xbindkeysrc
    "xdotool click 1"
      Alt_R
    "xdotool click 3"
      Menu

    xset -r 108
    xset -r 135
    pkill xbindkeys && xbindkeys
but I wish dragging a mouse click would also work.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#337
post #328

Earlier quoted context omitted.

One of the few aliases I always use is: alias rm='trash -i' It will prompt you before moving files to the trash instead of deleting them straight away on macOS. I've also added the -i flag to the following: alias mv='mv -i -v' alias cp='cp -i -v' alias ln='ln -i -v' It warns me when a file might be overwritten in the target directory and will display a short protocol of the actions performed due to the 'verbose' flag…

> alias rm='trash -i' This can really backfire. Ages ago, I used to have exactly the same alias for 'rm'. After a year or two, I got so used to 'rm' not really being destructive that one late night when I was really tired, I used it on a remote system without feeling the need to carefully check the file name. That remote system, of course, did not have 'rm' aliased to a safer version... Long story short, I strongly r…

I agree, yet I consider this to be the other way round. I treat "rm" still like a direct removal of the file and therefore use it with caution every time. Having it trash the file on my local machines is just a to me hidden fallback. But it is a very valid concern, of course.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#338

Honestly, the script/hack/automation I'm still most proud of is from around 1983, when I was 12 years old, for my Commodore 64. Back then, all computer communications were over the phone line, and in my house, we only had one line, so I spent a lot of late nights, dialing into BBSs, often not going to sleep until the sun came up. Then, I would get in trouble at school for falling asleep in class. So I came up with a…

I ran my own BBS on my Commodore 64 for about a year. I was completely hooked and lost a lot of sleep as well. My mother came to me one day and said "You really need to go outside"

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#339

This is more in the "hack" category, but here is a solution for bookmarking directories[1] that I am quite fond of: mkdir ~/.marks/ export CDPATH=.:~/.marks/ function mark { ln -sr "$(pwd)" ~/.marks/"$1"; } Then: mark @name # add bookmark called @name for the current directory cd @name # jump to the bookmarked location cd @ # list all available bookmarks It can list bookmarks, auto-complete, jump to sub-directories w…

I've been trying this for a few days and now noticed u-boot no longer builds with an output dir ( `make O=subdir whatever` ).

It sure took me ages to figure it was CDPATH, but CDPATH it is. I won't retry without making that "cd @" thing a subfunction (that might involve making its own completion, but that's easy compared to debugging make... I still don't know WHY it broke, just that it's CDPATH that broke it -- it decided to duplicate the subdir arg when invoking a submake so make was now left with a weird unknown target, but it obviously wouldn't say that and just failed weirdly)

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#340

This is more in the "hack" category, but here is a solution for bookmarking directories[1] that I am quite fond of: mkdir ~/.marks/ export CDPATH=.:~/.marks/ function mark { ln -sr "$(pwd)" ~/.marks/"$1"; } Then: mark @name # add bookmark called @name for the current directory cd @name # jump to the bookmarked location cd @ # list all available bookmarks It can list bookmarks, auto-complete, jump to sub-directories w…

I've been trying this for a few days and now noticed u-boot no longer builds with an output dir ( `make O=subdir whatever` ). It sure took me ages to figure it was CDPATH, but CDPATH it is. I won't retry without making that "cd @" thing a subfunction (that might involve making its own completion, but that's easy compared to debugging make... I still don't know WHY it broke, just that it's CDPATH that broke it -- it d…

Interesting, thanks for sharing. I would be tempted to call this a bug in the Makefile if this is the case. CDPATH is a standard bash environment variable, people use it in various ways: https://github.com/search?q=%22export+CDPATH%22&type=code

If all these causes the build to fail then the maintainers of that build should be informed.

Post reply on HN