0

Consider that we write on terminal cat file0.csv, and then get 1000 lines of code. After that, we write cat file1.csv and then we get other 1000 lines of code. And so forth till cat file5.csv.

Whenever we want to go up to the last line --let's say, to check if we write file*.csv correctly without using history or reverse search, or simply to consult the first results of our commands without repeating them using less or head-- the only method we have is SHIFT + Page Up, but it is so tedious when there are 1000 lines of code per file. It becomes even worse when you only have SHIFT + Page Down and what your are looking for is not close neither to your current position nor the last line of the terminal --making home and end keys not useful for this case--.

Thus, are there any shortcuts to jump up/down directly across the manually-typed lines of a bash terminal?

  • If you use a multiplexer, like tmux, you can just do a reverse search. – jasonwryan Feb 9 '17 at 6:29
  • try: (1) up-arrow; (2) CTR-R pattern to reverse search; (3) PgUp – JJoao Feb 9 '17 at 8:22
  • @jasonwryan Even in gnome-terminal you can search for a string that's unique in your prompt. – egmont Feb 9 '17 at 10:23
  • 1
    See bugzilla.gnome.org/show_bug.cgi?id=767230 for the feature request of directly supporting it. It's unlikely to be addressed in the near future, though :( – egmont Feb 9 '17 at 10:25
  • To add to some things mentioned above you can jump to the first and last character of a prompt you are typing with the home and end keys – Pythonic Feb 15 '17 at 17:08
0

[copy of an answer to a related question here]

One approach could be to have some unique text in your prompt (I use $ followed by a non-breaking space (PS1=$'$\ua0')).

And configure your terminal emulator to scroll-back to it upon some key press.

For instance, with GNU screen, in ~/.screenrc:

defscrollback 5000
bindkey \033` eval copy "stuff k?$\240\r"

Would map that to Alt+Backtick

I use GNU screen on all terminals and terminal emulators. Besides the many features brought by screen, that makes for a consistent experience on all of them, in particular with the scrollback handling (which is searchable, and which you can save to files or log, or copy-by-region... which most other terminal emulators are not capable to do).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.