There are well-known shortcuts to get arguments of the previous command in bash, like Alt+. or $!, etc. None of this is working in my zsh, I am using some zprezto modules. I was not able to find anything regarding this being changed by zprezto modules. Can it be some ZSH setting that I am missing or that I might have set and those disabled this behavior?

  • 2
    Have you tried starting from an empty zshrc and just enabling plugins one by one in order to find out where the culprit is? – slhck Aug 5 '18 at 16:22

ALT. is not to my knowledge well-known. I’m assuming this is defined by something you loaded in your bash startup. (What does it do for you?)

$! is the process id of the most recently started child process. I assume this is not what you intended to type. :)

!$ is a (shortened) history expansion that should under default circumstances expand to the last argument of the previous command. zsh’s history expansion is meticulously documented in the zsh manual.

History expansions usually starts with !, but it’s possible to change this by setting the value of $HISTCHARS: The first character of $HISTCHARS will be used as the character that initiates a history expansion. By default, $HISTCHARS is set to a value of !^#. You can check the value on your system with:


If this does not start with !, then something in your zsh startup has set a different value, and standard, well-known history expansions like !! and !$ will not work for you.


It turns out that the first paragraph I wrote above is dead wrong. I may not have known about ALT., but that may be due to the fact that I have “always” used zsh with vi mode enabled. In fact, ALT. (and ALT_, which does the same thing) are enabled in zsh’s default emacs keybindings. They’re bound to the ZLE widget insert-last-word, which does what you describe.

If you’re using zsh with the default emacs keybindings and ALT. is not working for you, then something you’re loading in your shell startup is overriding it. You can reestablish the default keybindings with:

bindkey -M emacs "^[." insert-last-word \
                 "^[_" insert-last-word

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.