Linux screen прокрутка экрана

Using the scrollwheel in GNU screen

How can I set up GNU screen to allow the mouse’s scrollwheel to scroll around in the scrollback buffer? I tried to Google about this, but most hits were on how to allow applications inside screen to use the scrollwheel.

JesperE — Can you change the chosen answer? I got confused, and the comments are right, the other answer is way better.

10 Answers 10

I believe you can just add a line like this to your ~/.screenrc :

Where «xterm*» is a glob match of your current TERM. To confirm it works, ^A^D to detach from your screen, then screen -d -r to reattach, then ls a few times, and try to scroll back. It works for me.

What is this magic? Well, let’s consult the manual pages.

termcapinfo term terminal-tweaks [window-tweaks] [..] The first argument specifies which terminal(s) should be affected by this definition. You can specify multiple terminal names by separating them with `|'s. Use `*' to match all terminals and `vt*' to match all terminals that begin with "vt". [..] Some examples: termcap xterm* LP:hs@ Informs screen that all terminals that begin with `xterm' have firm auto-margins that allow the last position on the screen to be updated (LP), but they don't really have a status line (no 'hs' - append `@' to turn entries off). Note that we assume `LP' for all terminal names that start with "vt", but only if you don't specify a termcap command for that terminal. 
String capabilities [..] te End program that uses cursor motion ti Begin program that uses cursor motion 

I followed Pistos’s suggestion, and it partially works. As he describes, I can enter some commands (to produce enough output to scroll the screen), and then use the mouse-wheel to scroll back through the preceding lines. In fact, I’m using screen via Konsole in KDE (tabbed xterm, basically), and the scrollbar for the Konsole window works the same way. But there’s a problem: If you switch between screen’s windows (^A-n, ^A-p), your scrollback buffer gets messed up. The contents of any windows you switch into will just get ‘tucked’ up into your scrollback buffer. That really diminishes it.

@JesperE: I experienced it scrolling the command history as well (I’m using Ubuntu’s GNOME terminal). I fixed it by going to Edit -> Profile Preferences -> Scrolling, and unchecking «Use keystrokes to scroll on alternate screen». Note that I still needed to use Pistos’s fix.

Читайте также:  Vipnet dst файл linux

In addition to working in OS X Lion, this also works in Putty, iSSH and Prompt (by Panic). This line should be present in all .screenrc files!

This enables scrolling in the terminal not scrolling in the screen session. I.e. if you work with split regions or switch a window you won’t be able to scroll back in this region and instead you’ll scroll back in the terminal output and see the output as it was before you split the region or changed the window.

In screen, you must first enter «scrollback mode» (or «copy mode») to be able to scroll around in the scrollback buffer: key combo Ctrl — a Esc , or Ctrl — a Ctrl — [ . Then you can scroll around the history using Up and Down keys (or Ctrl — b , Ctrl — f to move a page).

In that mode, your mousewheel should also work, if it works in other apps. You end «scrollback mode» with Esc .

As for scrolling the scrollback buffer without first entering scrollback mode, that is probably not possible without modifying screen. I have never heard of a way to access the scrollback buffer, apart from scrollback mode.

Yes, I know about scrollback mode. I was hoping that I would not have to manually enter scrollback mode in order to use the mouse. Thanks.

«Scrollback mode» is rather an unofficial term IMHO. 🙂 Ctrl+a Esc will enter the copy mode; this mode has always been called that, as its primary purpose is to make it possible to copy text to and fro. The possibility to scroll with the mouse wheel in copy mode (nb. does not work for me) should rather be seen as a kind of «additional gimmick», but not as the main purpose of this mode.

@syntaxerror: Well, the docs call it «copy/scrollback mode», and mention a «scrollback buffer» (gnu.org/software/screen/manual/screen.html#Copy-and-Paste ), so I guess we’re both right :-). Anyway, I added «copy mode» to my answer.

Great! I wanted to do this too, but before messing into such old answers, I am known for asking first (even though I am aware the SO/SE rules do not prescribe it; but that’s the thing with unwritten rules.)

The excellent article that Jon Z is referring to is no longer available, but I was able to fish the text-only version of it from the Google cache. I’m saving it here in case Google drops that as well in the future. Original post was by Mikael Ståldal so credit where credit is due.

How to use mousewheel in GNU Screen

GNU Screen has support for scrollback, but by default you have to use awkward keys to use it. I would like to be able to use Shift-PageUp, Shift-PageDown and the mousewheel to scroll, just like you can do in xterm.

It was not easy to configure Screen for this, and it involves cooperation with the terminal emulator. But I finally managed to achieve a solution which works pretty well. Add this to your ~/.Xresources file (you need to log out for this to take effect):

XTerm*saveLines: 0 XTerm*vt100.translations: #override \n\ Ctrl : string(0x1b) string("[25S") \n\ Lock Ctrl : string(0x1b) string("[25S") \n\ Lock @Num_Lock Ctrl : string(0x1b) string("[25S") \n\ @Num_Lock Ctrl : string(0x1b) string("[25S") \n\ : string(0x1b) string("[5S") \n\ Ctrl : string(0x1b) string("[25T") \n\ Lock Ctrl : string(0x1b) string("[25T") \n\ Lock @Num_Lock Ctrl : string(0x1b) string("[25T") \n\ @Num_Lock Ctrl : string(0x1b) string("[25T") \n\ : string(0x1b) string("[5T") \n\ Shift Prior: string(0x1b) string("[25S") \n\ Shift Next: string(0x1b) string("[25T") \n 

Then add this to your ~/.screenrc file:

defscrollback 1000 # Scroll up bindkey -d "^[[5S" eval copy "stuff 5\025" bindkey -m "^[[5S" stuff 5\025 # Scroll down bindkey -d "^[[5T" eval copy "stuff 5\004" bindkey -m "^[[5T" stuff 5\004 # Scroll up more bindkey -d "^[[25S" eval copy "stuff \025" bindkey -m "^[[25S" stuff \025 # Scroll down more bindkey -d "^[[25T" eval copy "stuff \004" bindkey -m "^[[25T" stuff \004 

This works in xterm. I’m not sure if it works in other terminal emulators.

Читайте также:  Настройка виртуализации astra linux

Note that this disables the normal scrolling support in xterm, you will only be able to scroll when using Screen. You might want to start xterm like this to always use Screen:

Источник

How to scroll up and down in sliced «screen» terminal

I just installed screen and like the idea to divide linux terminal into multiple pieces. But I can’t figure out one thing: How to scroll up and down, when I’m in screen . When I’m using regular linux terminal I can achieve this with Shift + Pg Up or Shift + Pg Dn `. but unfortunatelly it doesn’t work in divided terminal. That’s what I mean when saying screen and divided terminal: enter image description hereAnd that’s a regular termina (just in case): enter image description here

5 Answers 5

1. Ctrl + A , then Esc
2. After that, you should be able to move your cursor around using the arrow keys:
↑ , ↓ , PgUp , PgDn and sometimes using the mouse wheel
3. Return control: Q or Esc

@MihaiDanila: How would you «normally» use the navigation keys? The navigation keys are handled by the current foreground application. If it’s an editor, they’ll probably work. If it’s a shell, they’ll probably go back through your command history without scrolling the display.

If my pageup/pagedown keys work in a normal shell, I’d like for them to work in a shell from screen . I think that’s what I’m asking here.

in this mode selection of any text is available by typing Space or Enter key once and finish your text selection with another Space or Enter. the selection will enter into the screen based clipboard. you could paste clipboard data later using Ctrl+a then ]

Источник

GNU Screen

Для того чтобы прокрутить текст в screen, нужно перейти в режим прокрутки нажатием Ctrl-a [. После этого можно перемещаться по тексту стрелками и клавишами PgUp/PgDn.

Для того чтобы прокрутка заработала в привычном режиме, нужно добавить строку:

(верно только для сеансов Screen, запущенных в графическом терминале).

[править] Название программы в заголовке

В командных интерпретаторах tcsh и zsh задача решается очень легко. Там есть готовый механизм, позволяющий передавать имя программы наружу.

Для bash тоже можно добиться такого результата, но только с хитростями.

В конфигурационный файл screen нужно добавить строку, которая показывает каким символом заканчивается приглашение, и какое название окна следует использовать по умолчанию:

Читайте также:  Посмотреть pem сертификат linux

Кроме этого, нужно включить в PS1 последовательность ‘\[\033k\033\\\]’:

Теперь в названии окна будет автоматически отображаться имя исполняемой программы.

[править] Имя хоста в заголовке

Бывает часто, что из окон screen заходишь на разные хосты, а потом перебираешь окна в поисках хоста, который потерялся среди многочисленных окон. Можно сделать так, чтобы имя хоста, на который вы зашли из окна screen, отображалось в строке состояния и в заголовке окна.

Скрипт [2] необходимо вызывать при каждом заходе на удалённый хост.

Это будет происходить автоматически, если добавить в конфигурационный файл ssh строки:

Host * LocalCommand /path/to/screen_ssh.sh $PPID %n
hardstatus alwayslastline "% %[%%0c%]% [%-Lw%%%50>%n%f* %t%%%+Lw]%

[править] Переименование поредевших окон

а потом вы закрыли несколько, и стало:

[править] Запуск команд на отключенном Screen

Screen можно запустить в отключенном сразу режиме. Например:

screen -m -d tail -f /var/log/messages

Потом к нему можно будет подключиться и использовать его. Можно даже и не подключаться, просто использовать программу по сети.

Сессией screen можно будет управлять с помощью вызова

здесь вместо screen-command может быть любая команда screen (примеры: [5]).

Но что интересно, некоторые команды работают, только если к скрину хотя бы один раз подключиться. Например:

screen -S example -m d tail -f /var/log/messages screen -S example -X title messages

Здесь заголовок окна не поменяется.

А если экран хотя бы раз подключить, а потом опять отключить, то эти же команды будут работать нормально.

Некоторые команды работают нормально сразу. Например, открытие новых окон с помощью screen -X screen.

[править] Замедленная вставка текста из буфера

Для того чтобы текст из буфера обмена GNU Screen вставлять не на полной скорости, а с задержками, можно использовать команду slowpaste.

При вставке GNU Screen будет ждать 100 мс после каждого символа.

[править] Подсветка вертикального разделителя другим цветом

so расшифровывается как standout.

[править] Как запускать графические приложения из старого screen после перезапуска X'ов?

[править] Можно ли объединять в группы экраны GNU Screen?

Да. Читайте про group.

[править] Можно ли чтобы состояние регионов в Screen сохранялось после отключения/подключения?

[править] Как увеличить буфер прокрутки?

С перезапуском: добавить в ~/.screenrc

Посмотреть величину буфера прокрутки можно, нажава ctrl-a i.

[править] См. также

[править] Дополнительная информация

  • Using screen for remote interaction (англ.) — Статья, рассказывающая о том, как использовать GNU Screen для удалённого взаимодействия; в частности в ней рассказывается как организовать доступ к экрану в режиме readonly
  • Unbreaking GNU Screen (англ.) — Заметка о том, как бороться с неудобствами GNU Screen: отключением стандартного механизма прокрутки, альтернативным экраном и захватом комбинации Ctrl-A (подробнее что такое альтернативный экран (alternate screen) можно почитать здесь [9])
  • TIP Using screen (англ.) — огромнейшее количество полезных советов по использованию GNU Screen. Рекомендуется читать всем продвинутым пользователям GNU Screen. Начинающим тоже можно
  • New screen features available (англ.) — новые возможности Screen, которые пока что не описаны в мане, но уже доступны. В частности вертикальный сплит (ctrl-a |)
  • .screenrc (англ.) — Примеры
  • Screen notes @ noah.org (англ.) — некоторые хитрые примеры использования GNU Screen

[править] Оконные менеджеры на Xgu.ru

Источник

Оцените статью
Adblock
detector