Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Silly question on :h and = expansion
- X-seq: zsh-users 26937
- From: Zach Riggle <zachriggle@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Silly question on :h and = expansion
- Date: Tue, 17 Aug 2021 12:39:07 -0500
- Archived-at: <https://zsh.org/users/26937>
- List-id: <zsh-users.zsh.org>
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