有时我们只需要在使用mv/cp/convert
. 例如,
convert IMG-long-number.jpg IMG-long-number.png
Run Code Online (Sandbox Code Playgroud)
如何在输入IMG-long-number.png之前重复IMG-long-number.jpg,所以我只需要做一些小的调整?
这类似于如何在 bash 控制台上重复当前输入的参数?但是对于 zsh/zle。
!#$<Tab>
为我工作。鉴于:
$ echo a
Run Code Online (Sandbox Code Playgroud)
键入!#$
然后按Tab扩展!#$
到a
。如果您尝试使用以下操作,选项卡完成还会列出其他选项:
:
$ echo a !#$:
& -- repeat substitution
A -- absolute path resolving symbolic links
Q -- strip quotes
a -- absolute path
c -- PATH search for command
e -- leave only extension
g -- globally apply s or &
h -- head - strip trailing path element
l -- lower case all words
q -- quote to escape further substitutions
r -- root - strip suffix
s -- substitute string
t -- tail - strip directories
u -- upper case all words
Run Code Online (Sandbox Code Playgroud)