Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Silly question on :h and = expansion



Quick question, the answer is probably "just use dirname".

I really like the flexibilty of Zsh expansion, particularly "=foo" to
effectively expand to the full path, and as best I know it's
functionally equivalent to "${commands[foo]}".

I also like the ":h" modifier that's equivalent to "dirname" (and all
of its siblings, but that's the only relevant one for this post).

I would like to simplify the process of "print the directory
containing" or "cd to directory containing" some file in $PATH.

I know I can do either of

* $(basename =foo)
* ${commands[foo]:h}

But I was hoping there was a way to combine the "=" and ":h" expansion
into one line.  As best I can tell, there isn't -- but I figured it
was worth asking.

Zach Riggle




Messages sorted by: Reverse Date, Date, Thread, Author