Is there any known way to achieve the "insert last command argument"-functionality that is usually available in Bash by typing Alt-. (Alt and period) on OSX using iTerm2?

The ways I know this should be possible is by the two key-sequences:

Alt + .
Esc + .

The Esc-. one works, but the Alt-. does not. Not with Alt-. or Cmd-.


3 Answers 3


This looks like part of the EMACS readline bash key bindings i.e. they appear to be key combinations that are used in EMACS and emulated or add-ons to bash, or something. Mine work as yours do, unfortunately, but I have a workaround since you are speaking with respect to iTerm2:

Go into the Preferences for the profile of the Terminal session you'd like to inflict this upon, and establish the key-binding as illustrated thus:

enter image description here

This is probably not the solution that you are looking for, however it should work for you in a pinch.

  • This works great for me. If it's not the right solution, what is?
    – GDorn
    Oct 25, 2016 at 19:32

You simply need to modify the behavior of the Option key to achieve the desired result.

If you navigate to the Keyboard Behavior section of the Keys tab in the Profile setting, you'll see that the "Left/Right option (⌥) key acts as:" choices are set to "Normal" (as in the screenshot in Bill's answer). Update these to "+Esc" and apply.  Alt+. will now provide the last argument of the previous command.

  • 1
    Edit your answer and provide detail steps to accomplish what you describe
    – Ramhound
    Jan 12, 2017 at 5:32
  • @iviarki: This will affect the behavior of all (Alt)+ key combinations, won't it? Jan 12, 2017 at 5:37
  • Not sure why someone downvoted. The above works. Although compared to other answer here you'd use 'alt' (option) as oppose to command button. Jan 3, 2019 at 21:45

iTerm2 > Settings > Profiles > Keys > Left Option key > Esc+

enter image description here

  • 1
    This sets if for ⌥, not ⌘. Still, better than nothing.
    – malana
    Dec 20, 2022 at 11:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .