17

Mac OS X Terminal marks are incredibly useful.

For example, when I type a command that echoes a lot output, it's easy to read the beginning with Cmd+Up. It will scroll to the last command and highlight it, since there's the option Automatically Mark Prompt Lines and Cmd+Up will scroll to the last mark.

Is there any terminal emulator with this functionality? Or some plugin, whatever. How do you go fast to the last command, highlighting it?

2
  • 2
    Not that I'm aware of (apart from, of course, Mac OS X Terminal; and presumably iTerm2 with its shell integration having something quite similar). I find this a really useful idea and have filed an enhancement request for vte/gnome-terminal: bugzilla.gnome.org/show_bug.cgi?id=767230.
    – egmont
    Commented Jun 4, 2016 at 7:41
  • @egmont Thanks, it would be superb having it on GNOME Terminal.
    – rodorgas
    Commented Jun 4, 2016 at 17:50

3 Answers 3

6

This is workaround - not a solution.

I run the reset command before a command with a long output. Something like

$ reset
$ cat some-long-file.txt

Then I press Ctrl+Shift+Home (in the Xfce4 Terminal Emulator) to scroll to the beginning of the terminal history.

The downside is that the previous terminal history is lost but sometimes it is acceptable.

3

VTE based terminals, such as e.g. GNOME Terminal, GNOME Console, Xfce4 Terminal, Terminator, Tilix, Guake and more, support jumping between prompts since the GNOME 46 (VTE 0.76) release in March 2024.

The hotkey is hardcoded for the time being, it's Ctrl+Shift+Left and Ctrl+Shift+Right.

Under the hood, VTE uses the quasi-standard OSC 133 shell integration escape sequences to see where the prompts are, like several other terminals already do.

There's no generic marks support yet, you cannot manually place such stopping points.

10
  • What needs to be done in the prompt for it to be recognized? On my Arch system, with vte4 0.76.0-2 (used by GNOME Console KGX 46.0 using VTE 0.76.0 +BIDI +GNUTLS +ICU +SYSTEMD) and vte3 0.76.0-2 (used by Terminator 2.1.3), Console jumps to the top and Terminator does nothing.
    – muru
    Commented Mar 24 at 6:07
  • You need to source /etc/profile.d/vte.sh (or whatever the exact filename is) in your bash or zsh. That sets up the prompt. If you use a different shell then this script should guide you what to do. This should fix it in Console (if it jumps to the top then it means it simply didn't see any prompt).
    – egmont
    Commented Mar 24 at 10:40
  • In Terminator Ctrl+Shift+Arrows are configured by default to resize panes. You'll need to remove these shortcuts in its config, or e.g. move them to e.g. Ctrl+Alt+Arrows as in Tilix. This is something I should mention in my answer :)
    – egmont
    Commented Mar 24 at 10:42
  • Terminator: filed github.com/gnome-terminator/terminator/issues/897.
    – egmont
    Commented Mar 24 at 10:58
  • 1
    Ah, I see what's going on now. I'm using a zshrc which sets PS1 anew for each prompt (akin to using PROMPT_COMMAND to set PS1 in bash), so the modifications from /etc/profile.d/vte.sh were lost. Using my prompt theme's customization options to add back OSC 133;A ST/OSC 133;B ST to the start and end, it started working in GNOME Console. Thanks for the pointer! I suppose, like with using PROMPT_COMMAND to set PS1 in bash, this is not something a maintainer would be reasonably expected to accommodate.
    – muru
    Commented Mar 24 at 12:19
1

Your best bet is to use the search feature of your terminal buffer. Press:

$ ctrl+shift+f

to enter search mode. Then type part (or all) of your last command and it scrolls back highlighting the search term. Press ESC key (escape) to get out of the search mode.

This site is temporarily in read-only mode and not accepting new answers.

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