News for hackers. Stuff that matters.
Re:Ask HN: What's the best obscure but useful CLI tool? by john-tells-all on Wednesday April 05, 2023 @11:58AM (#35456280)
entr -- when a file changes, run a command

I use this on literally 100% of my projects. Normally it's "when my source changes, run tests" or sometimes "when files change, do 'terraform plan' to see what would change".

Using this one command shortens developer feedback loops from a minute to microseconds! And you don't have to think about it! It's magic.

`ls -1 *.py | entr pytest`

`git ls-files | entr terraform plan`

For more, see our friend and national treasure Julia Evans: https://jvns.ca/blog/2020/06/28/entr/

Re:Ask HN: What's the best obscure but useful CLI tool? by lordleft on Wednesday April 05, 2023 @01:46PM (#35457852)
That is incredible, I had no idea this existed -- thanks for sharing!
Re:Ask HN: What's the best obscure but useful CLI tool? by qup on Wednesday April 05, 2023 @04:35PM (#35460007)
20+ years of linux, didn't know about it. Will be daily-driving it now, thanks for chiming in.
Re:Ask HN: What's the best obscure but useful CLI tool? by rthomas6 on Wednesday April 05, 2023 @04:54PM (#35460235)
That's awesome. Seems like it would pair well with Make.
Re:Ask HN: What's the best obscure but useful CLI tool? by coreyp_1 on Wednesday April 05, 2023 @06:10PM (#35461091)
I use inotifywait with make for a similar effect. I save a source file and my code is re-compiled and tests are run.

I love it!

Re:Ask HN: What's the best obscure but useful CLI tool? by john-tells-all on Wednesday April 12, 2023 @12:31AM (#35535024)
absolutely. 100% of my projects use Entr ("run thing on file change"), and Make ("use short name to run a complex script, e.g. test -> pytest").
Re:Ask HN: What's the best obscure but useful CLI tool? by anthonyhn on Wednesday April 05, 2023 @03:50PM (#35459517)
GNU Parallel is pretty useful. You can use it to run command line programs in parallel. For example, if you wanted to gzip compress all individual files in a directory and limit the number of jobs equal to the number of CPU cores on your machine:

ls | parallel --dry-run --jobs `nproc` 'gzip {}'

(Note you have to remove the --dry-run switch to actually run this, --dry-run only prints out the commands parallel will run, not actually execute them)

Re:Ask HN: What's the best obscure but useful CLI tool? by qhwudbebd on Wednesday April 05, 2023 @04:21PM (#35459851)
Sometimes xargs -P is useful too, but it's much more limited than GNU parallel.
Re:Ask HN: What's the best obscure but useful CLI tool? by hayst4ck on Thursday April 06, 2023 @08:48PM (#35476650)
I think `xargs -P -I` is probably the closest thing to magic when it comes to commands.
Re:Ask HN: What's the best obscure but useful CLI tool? by rthomas6 on Wednesday April 05, 2023 @05:01PM (#35460323)
yes: literally just type y, or whatever string, over and over again.

  yes | annoying_interactive_install_script.sh
Re:Ask HN: What's the best obscure but useful CLI tool? by hosteur on Friday April 07, 2023 @03:02PM (#35485629)
jdupes I find myself using it rather frequently. It is fantastic to find duplicate files.