Hacker News new | past | comments | ask | show | jobs | submit login

I have a similar but different need, wonder if anyone has the same frustrations and knows a solution:

I often press enter key a few times to produce a noticeable gap between different runs of the same command. Yes, in theory, the shell prompt is enough to separate the runs, and I could customize the color, font etc, but that's still not as good as a few (almost) blank lines.

The workflow is like this: often I need to run a command that produces a decent amount of output and repeat that a few times. Not 3 lines, not 1k lines, but something like 40-100 lines -- not short enough that I can easily see both the beginning and the end, not long enough that I have to log it to a file. I want to be able to scroll to the top of the output and read it.

The "multiple enter key" approach works well enough, but is a bit repetitive and sometimes I forget to do that (then can't find where the output begins). I could also append printf "\n\n\n" but apparently it's annoying. I wonder if there is something simpler and works well. The tool in this article doesn't exactly match my need, as it prints a spacer immediately after output pauses, not after a command finishes.




macOS’s built-in Terminal.app has a feature I love for this, which I haven’t seen anything else replicate, which is that pressing Cmd-Up just scrolls up to the last command prompt in your scroll buffer. Just press it as many times as you want to find the beginning of previous commands you typed.

I’m not sure how it’s implemented… maybe they take note of what your prompt looks like and generate a regex for it? Or maybe they take note of when the last time it was that your shell process had no child processes and read from stdin… but it works quite reliably.


Personally, I have a command called `--` that prints a terminal-wide horizontal red line using ‘━’ (U+2501 if HN eats it). So I run things like

   $ --; make noisy-build
Then I can see the start easily when scrolling back.


You could temporarily change your prompt:

  export PS1="\n\n\n\n\n\n$PS1"
Or if the repeated prompt is part of your visual pattern matching:

  export PS1="$PS1\n$PS1\n$PS1\n$PS1"


Or

  # ~/.bashrc
  alias p5='printf "\n\n\n\n\n"'

  # run
  my-command; p5
May also add 100 '-'s before or after newlines for better separation.


Hmm... this looks like it works, to save in bashrc and activate it once:

  alias p6='export PS1="\n\n\n\n\n\n$PS1"'
  p6
  my-command
  my-command


I’m writing a terminal emulator that solves this (and many other) common problems with the CLI. For example, one of its features is it highlights command output so you can easily see where each commands output is.

You can also collapse output too

https://github.com/lmorg/mxtty


Sometimes its nice to use something like tmux for this. Open a new pane for such a run and all output will be in the scroll buffer of that one pane.


As a windows user, the fact that hitting a button immediately would reflect inside a running output stream, feels strange. But its benefit is clearly shown here.


iTerm on macOS does this. It calls them "marks", and you can set them anywhere, but by default it creates a mark for each prompt. You can then jump between them with cmd-arrow. iTerm also suppers showing the timestamp of each line, and it visualizes this in a nice way where lines emitted around the same time have their timestamps replaced with a vertical line.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: