12

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-.

22

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 '16 at 19:32
0

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.

  • Edit your answer and provide detail steps to accomplish what you describe – Ramhound Jan 12 '17 at 5:32
  • @iviarki: This will affect the behavior of all (Alt)+ key combinations, won't it? – Scott Jan 12 '17 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. – Leo Ufimtsev Jan 3 at 21:45

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.