Filename expansion with = in ZSH
I do this somewhat often to find where a binary exists in my $PATH.
For a script in my path, I might also do something like this to quickly edit it.
$ echo `which ls`
$ vi `which myscript.py`
The other day, I learned about a handy little shortcut ZSH provides:
$ echo =ls
/bin/ls
$ what =ls
/bin/ls:
PROGRAM:ls PROJECT:file_cmds-479
Copyright (c) 1989, 1993, 1994
PROGRAM:ls PROJECT:file_cmds-479
Copyright (c) 1989, 1993, 1994
From the “Filename Expansion” section of zshexpn(1):
`=' expansion
If a word begins with an unquoted `=' and the EQUALS option is set, the
remainder of the word is taken as the name of a command. If a command
exists by that name, the word is replaced by the full pathname of the
command.
This doesn’t work in sh(1) or bash(1); it’s a ZSH thing. The EQUALS option
is set by default.
EQUALS <Z>
Perform = filename expansion. (See the section `Filename Expansion'.)