With the default Terminal.app, one can select the previous command output with Cmd + Shift + A and then copy it with Cmd + C (source).

Is there a similar shortcut for iTerm2?

2 Answers 2


I figured out the solution:

  • Install Shell Integration: iTerm2 > Install Shell Integration
  • Restart iTerm2 (or just source the script)
  • Run some command that produces output, e.g. pwd
  • Verify that Edit > Select Output of Last Command is enabled, and that the shortcut Cmd + Shift + A works as well.

Note: the solution also works over SSH if you source the shell integration script

  • 3
    @SidaZhou It does work when you SSH to a machine, as long as the remote shell also sources the shell integration script. Sep 20, 2021 at 23:19
  • 1
    Please note that restarting iTerm2 is not necessary, as long as the shell integration script is sourced after installation
    – Giuseppe
    Jan 22, 2022 at 9:46

It works exactly the same for iTerm2 at least in El Capitan.


You must log in to answer this question.

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