News for hackers. Stuff that matters.
Re:Cdpath: Easily Navigate Directories in the Terminal by brushfoot on Thursday December 07, 2023 @08:00AM (#38555822)
On Windows, I used to use AutoHotkey hotstrings for that so that they'd be available in file dialogs and Explorer as well as the terminal. Example:

    ::$pmd::C:\my\directory
For those unfamiliar with AutoHotkey, it has a global keyboard hook that watches for hotstrings like this and expands them to the text after the second pair of colons.

"$" is a sigil I chose to use for all hotstrings since I didn't use a language that used it and it helped avoid collisions with text that wasn't meant to be a hotstring, "p" was my prefix for pathing hotstrings, and "md" was an abbreviation for the mnemonic I chose for this particular directory, "my directory."

Then I realized z saves you the work of all that by learning which directories you use regularly and letting you switch to them with partial matching on its arguments:

    z my dir
No more coming up with mnemonics and editing my hotstrings file when I started new projects; now z handles it.

For the GUI (file dialogs etc.), my profile script now includes a command that copies the current directory to the clipboard. I'm happy with that workflow since I pretty much always have a terminal open anyway.

There are no comments on this comment yet.