News for hackers. Stuff that matters.
Re:A shell exclamation mark is not for yelling. Be lazy. by mkl on Wednesday August 12, 2026 @08:18AM (#49271232)
> alt-. is great for what it is designed to do, iterating over the previous "last arguments" of your shell history. It's great at doing that, but it is also limited to doing just that one thing.

No, it isn't limited to just that. Alt-0 alt-. will give you the zeroth "argument" (the program), alt-1 alt-. will get you the next (the program's first argument), etc. Negative arguments count back from the end: alt-- 1 alt-. will get you the argument before the last one (note that alt is held for the "-" but not the digit).

When you do use event designators, ctrl-alt-e (or alt-^) is critical. It expands all the ! codes inline to what they refer to, so you can see what you're doing before you hit enter, and as you're constructing the command too.

Re:A shell exclamation mark is not for yelling. Be lazy. by refp on Wednesday August 12, 2026 @08:30AM (#49271373)
Author here, thanks for reading and taking time to reply!

---

You are very much correct that `Alt-.` with modifiers can do more than what has been described, it is however important to note that the behavior of `Alt-<key>` changes heavily both between zsh and bash, but also between `vi-mode` and `emacs-mode`.

For instance, zsh will switch to `vi-mode` depending on env variables such as `$EDITOR`, making `Alt-<key>` unavailable in that regard.

---

It's also worth noting that `ctrl-alt-e` is _not_ a zsh default, though it is a fair point that it could have been added in the below linked section:

https://refp.se/articles/your-shell-and-the-lazy-exclamation...

For what it's worth, I had troubles finding a proper scope for the article contents — and with that the lines became a bit blurry in terms of what to include, and what not to include.

---

I really appreciate constructive comments like yours, and hope it together with the article can help future shell ninjas!

Re:A shell exclamation mark is not for yelling. Be lazy. by refp on Wednesday August 12, 2026 @08:43AM (#49271519)
Also, on the note of "you can do everything with Alt-<key>", I'd like to highlight that modifiers such as `:h` (directory part), `:t` (filename), and `:r` (strip extension) etc., is what the article was aimed at when saying you can do more with event-designators.

What you can do with what is always hard to answer given that all roads lead to Rome, though some roads have more turns than others.

Re:A shell exclamation mark is not for yelling. Be lazy. by arijanj on Wednesday August 12, 2026 @09:31AM (#49272138)
This article taught me about alt-. and it's probably going to become my new favorite fish shortcut: if I type a portion of a word (for example an ssh hostname), hitting alt-. searches all previous arguments and autofills the entire username+hostname at that position. Seems much more powerful than bash's implementation. (and allows you to go forward/backward with alt+arrow keys if you overshoot it)
Re:A shell exclamation mark is not for yelling. Be lazy. by mturmon on Wednesday August 12, 2026 @09:58AM (#49272508)
Instead of alt-^, I set “magic-space” in `.inputrc`.

This will expand the event designator after you type space to end it. So you type “!” “$” “space” and the designated argument expands in-place.

Re:A shell exclamation mark is not for yelling. Be lazy. by bandie91 on Wednesday August 12, 2026 @08:44AM (#49271538)
i use `shopt -s histverify` instead of ctrl-alt-e.