Copy the output of the last command in iTerm2
Solution 1
I figured out the solution:
-
Install Shell Integration:
iTerm2
>Install Shell Integration
- Restart iTerm2
- 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
Solution 2
It works exactly the same for iTerm2 at least in El Capitan.
Juuso Ohtonen
Interests: Android, Python, Continuous integration (Jenkins) Android developer database by their location: http://www.androidtalents.com Some references on Android apps: Word Game http://goo.gl/F86Qnd and the Finnish web site: http://www.sanapeli.net/ Shopping List: https://play.google.com/store/apps/details?id=net.sanapeli.shoppinglist ADB Change Language helper app for developers: https://play.google.com/store/apps/details?id=net.sanapeli.adbchangelanguage Base Converter: https://play.google.com/store/apps/details?id=net.sanapeli.baseconverter Barcode to Price Comparison application (in Finland): https://play.google.com/store/apps/details?id=net.sanapeli.hintavertailu SOreadytohelp
Updated on September 18, 2022Comments
-
Juuso Ohtonen almost 2 years
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?
-
Juuso Ohtonen almost 7 yearsIt does not work for me on El Capitan. Or is it a configuration issue in iTerm2?
-
Juuso Ohtonen almost 7 yearsThanks to you @Vivien, I figured out what the problem was and added it as an answer.
-
Vivien Garcia almost 7 yearsNice clarification @JuusoOhtonen. I didn't thought about Shell Integration. It seems I had all the steps done right without trying :)
-
Harrison Cramer over 4 yearsThis is great. Thanks!
-
Sida Zhou almost 4 yearsNote that this doesnt seem to work on remote machines
-
Franklin Yu almost 3 years@SidaZhou It does work when you SSH to a machine, as long as the remote shell also sources the shell integration script.
-
Sida Zhou almost 3 years@FranklinYu Holy **** *****, IT WORKS!! This is the answer I've been searching all my life. Can you edit the answer to highlight this? Documentation doesnt seem to mention this case.
-
Giuseppe over 2 yearsPlease note that restarting iTerm2 is not necessary, as long as the shell integration script is sourced after installation