zsh-users
 help / color / mirror / code / Atom feed
* Silly question on :h and = expansion
@ 2021-08-17 17:39 Zach Riggle
  2021-08-17 17:59 ` Bart Schaefer
  2021-08-17 21:31 ` Paul
  0 siblings, 2 replies; 10+ messages in thread
From: Zach Riggle @ 2021-08-17 17:39 UTC (permalink / raw)
  To: Zsh Users

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-18  3:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 17:39 Silly question on :h and = expansion Zach Riggle
2021-08-17 17:59 ` Bart Schaefer
2021-08-17 21:35   ` Roman Neuhauser
2021-08-17 21:49     ` Bart Schaefer
2021-08-17 23:27       ` Zach Riggle
2021-08-18  0:12         ` Bart Schaefer
2021-08-18  2:55           ` Mikael Magnusson
2021-08-18  3:25             ` Bart Schaefer
2021-08-17 21:31 ` Paul
2021-08-17 21:39   ` Roman Neuhauser

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).