26

In Terminal, I can simply to cmd+up arrow. How can I do this in iTerm2? I've tried the cmd+shift+up arrow option, but it doesn't work reliably, especially when there is a currently running process.

Logan
  • 1,575
  • 1
  • 17
  • 26
  • 1
    There used to be one and i used it all the time. I just now looked through the keyboard mappings under settings and tried adding a new one. Nothing in the list for what we are looking for. So for some reason it was removed. Big bummer :( – HankCa Dec 05 '18 at 07:35
  • 1
    This feature doesn't seem to exist any more. It used to. This is not an answer, however you can turn on timestamps (command+shift+E) and you can quickly visually see the command-lines when you scroll back (make sure infinite scroll is on!). – HankCa Dec 05 '18 at 07:39
  • Ignore my 2 comments (ignore the first). It didn't appear until after I added the second. – HankCa Dec 05 '18 at 07:40
  • In iTerm 3.2.6 there are marks in `Edit > Marks and annotations` – vault Dec 13 '18 at 12:13

1 Answers1

32

You can do this with Shell Integration! By default, iTerm2 is not fully integrated with the shell (e.g. Bash) itself. It doesn't really know which lines are prompt and which are output, so it wouldn't know what line to jump you back to as the previous prompt. If you install shell integration, it'll automatically add a mark at each prompt line and you'll be able to cycle up and down with Command-Shift-Up Arrow and Command-Shift-Down Arrow respectively. On my machine this worked even while a process was running.

In Preferences > Keys you can change the default keybindings back to what you're used to. Double click on Command-Up Arrow, change the Action to Select Menu Item..., and set the menu item to Edit > Marks and Annotations > Previous Mark/Annotation. Repeat with Next Mark/Annotation for Command-Down Arrow.

EDITED 2020-03-30: It appears Mark and Annotation were separated into different menu items in a recent update. You should now use Next Mark instead.

Jordan Ticktin
  • 435
  • 4
  • 8
  • 1
    Thank you! I wanted to add that once you install Shell Integration, iTerm adds mark indicator arrow to the left of each command prompt. If you want to hide those arrows you can do so by going to **Profiles -> Open Profiles -> Edit Profiles -> Select your profile -> Terminal -> Uncheck "Show mark indicators"** (solution found [here](https://stackoverflow.com/a/41661660/2344177)). – Employee Feb 05 '21 at 19:39