Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The 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?


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`.


Understood. I'd rather write it myself from scratch than use an LLM; confirmation of the general process should be enough, I hope!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: