CD to folder in Terminal.kmmacros (4.4 KB)
Inspired by a macro From @Nige_S to list all Python scripts in a folder via F4.
Demo:

CD to folder in Terminal.kmmacros (4.4 KB)
Inspired by a macro From @Nige_S to list all Python scripts in a folder via F4.
Demo:

So purpose of this macro is to provide a menu of subdirectories in the current directory.
It’s an interesting idea and implementation, but why would one use this macro? Is it a “proof of concept” or did you have a use case in mind?
The choice of the Tab key for the trigger is surprising, because that’s very useful within the Terminal, e.g. within the home folder, cd doc followed by Tab will expand the command to cd Documents (if that’s the only match; otherwise more characters can be typed to provide the desired match).
With or without the macro, cd .. (or an alternative) is still needed to go back to the parent directory.
Relevant utilities that might be of interest:
That’s why I added “..\n” to the variable with directory names.
Thank you for the reference to autojump and zoxide. I already suspected that something like that would be available for macOS. Focussing on autojump, I like the list with directory names. I already had the idea to add something like that to the only “hard coded” item “..\n”. Probably it’s best to create a small file, listing my frequently visited directories (e.g. /Users/hl/Library/CloudStorage/Dropbox/CT/Scripts/Python/api).
Done! Macro file:
CD to folder in Terminal.kmmacros (5.1 KB)
Screenshot:
Edit: I added this “ls” command, because in 93.5 % of the cases, I also want to know what’s in the directory.
I’ve now added some lines to open the target directory also as a folder in the Finder. The folder is minimized to the Dock then. And in order to prevent overloading the Dock with minimized Finder windows, I close all of them first. Quite drastic, of course. But not a problem for me, since I very seldom minimize windows (I also maximize nearly every window.)
Ideas, simplifications and other improvements are welcome ![]()
CD to folder in Terminal.kmmacros (12.0 KB)
You can add aliases to paths:
/Users/hl/
/Users/hl/Library/CloudStorage/Dropbox/CT/Docx
/Users/hl/Library/CloudStorage/Dropbox/CT/Jobs
/Users/hl/Library/CloudStorage/Dropbox/CT/Scripts/Python/api
/Users/hl/documents
/Users/hl/pycat
/Users/hl/simpelvertaler
{ctest}/Users/hl/Library/CloudStorage/Dropbox/CT/Pro/test
You have to add one extra S&R action:
The default shell, zsh, should provide such name completion for you, regardless of the terminal application. I can confirm that it does work for me in the standard Apple Terminal under MacOS 15.7.7 (Sequoia).
Oh pardon me; somehow I must have missed that, despite having looked for such an obviously essential feature!
Since this is a posted macro, I have moved the topic to the Macro Library category.