Эмулятор терминала с функцией «восстановления сеанса», такой как Mac Terminal

Терминал Mac может восстановить предыдущий сеанс. Я только что перезагрузил MacBook, и когда терминал открылся, все мои предыдущие команды были на дисплее и на всех вкладках, как будто он никогда не закрывался. Существует только небольшое уведомление о дате восстановления.

Существует ли эмулятор терминала для Ubuntu с аналогичной функцией?

5
задан 23 November 2017 в 02:28

1 ответ

Один хороший способ наличия терминальных сеансов, которые сохраняются, состоит в том, чтобы выполнить 'экранную' сессию на сервере. 'Экранная' сессия дает Вам несколько окон на том сервере, где Вы можете быть зарегистрированы к другим машинам или что бы то ни было. У Вас может быть несколько 'экранных' сессий, работающих на сервере. Можно разъединиться и снова соединиться с сессиями, в которых Вы нуждаетесь. 'экран' является олдскульной клавиатурой командной строки, но определенно стоящий изучения и играть с изучить, как это работает. Википедия описывает screen хорошо "Экран GNU является оконечным мультиплексором... позволяя пользователю получить доступ к нескольким отдельным сессиям входа в систему в единственном окне терминала... удаленный процесс продолжает работать, даже когда пользователь разъединяется". Это имеет несколько больших преимуществ:

  • легкий установить, работает на любом Unix (или cygwin), никакая необходимая графика (помимо терминальной текстовой графики)
  • дает персистентные оконные терминальные сеансы (как долго, поскольку сервер не перезагружается),

Быстрый запуск экрана * *

Прочитайте руководство: экранное руководство пользователя gnu.org

  • screen - Выполненный экран для создания новой сессии просто

  • screen -ls - перечислите экранное выполнение сессий

  • screen -r 20229.pts-2.bangor - повторно прикрепите к сессии

* символ экрана ESCAPE по умолчанию Ctrl-a *, если некоторый сумасшедший выполняющий мертвую петлю летчик не изменил его в .screenrc, например, "Escape ^Zz" для людей, которые не оценивают управление фоновой обработкой процесса. Получить реальное Ctrl-a к терминалу (goto начало строки) при выполнении на экране затем просто делают Ctrl-a Ctrl-a.

  • ESCAPE c - создает новое экранное окно

  • ВЫЙДИТЕ 0 (или 1 2 3 4 5 6 7 8 9) - переключаются на окно 0 (или 1 2..)

  • ВЫЙДИТЕ из p или ВЫЙДИТЕ из n - переключаются на предыдущее или следующее окно

  • ESCAPE "-список окна

  • ESCAPE h - показывает экранную справку:

                                           Screen key bindings, page 1 of 1.

                                           Command key:  ^A   Literal ^A:  a

 break      ^B b        help       ?           monitor    M           remove     X           version    v         
 clear      C           history    { }         next       ^@ ^N sp n  removebuf  =           width      W         
 colon      :           info       i           number     N           reset      Z           windows    ^W w      
 copy       ^[ [        kill       K           only       Q           screen     ^C c        wrap       ^R r      
 detach     ^D d        lastmsg    ^M m        other      ^Z          select     '           writebuf   >         
 digraph    ^V          license    ,           pow_break  B           silence    _           xoff       ^S s      
 displays   *           lockscreen ^X x        pow_detach D           split      S           xon        ^Q q      
 fit        F           log        H           prev       ^H ^P p ^?  time       ^T t      
 flow       ^F f        login      L           readbuf    <           title      A         
 focus      ^I          meta       z           redisplay  ^L l        vbell      ^G        

^]   paste [.]
"    windowlist -b
-    select -
0    select 0
1    select 1
2    select 2
3    select 3
4    select 4
5    select 5
6    select 6
7    select 7
8    select 8
9    select 9
I    login on
O    login off
]    paste .
|    split -v
:kB: focus prev






                                            [Press Space or Return to end.]

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

$ экранируют-ls существуют экраны на: 24560.pts-6.mabrowka (Отсоединенный) 20229.pts-2.mabrowka (Присоединил) 2 Сокета в/var/run/screen/S-garmon.

$ экранируют-r 20229.pts-2.mabrowska

справка командной строки:

> $ screen --help Use: screen [-opts] [cmd [args]]  or: screen -r
> [host.tty]
> 
> Options:
> -4            Resolve hostnames only to IPv4 addresses.
> -6            Resolve hostnames only to IPv6 addresses.
> -a            Force all capabilities into each window's termcap.
> -A -[r|R]     Adapt all windows to the new display width & height.
> -c file       Read configuration file instead of '.screenrc'.
> -d (-r)       Detach the elsewhere running screen (and reattach here).
> -dmS name     Start as daemon: Screen session in detached mode.
> -D (-r)       Detach and logout remote (and reattach here).
> -D -RR        Do whatever is needed to get a screen session.
> -e xy         Change command characters.
> -f            Flow control on, -fn = off, -fa = auto.
> -h lines      Set the size of the scrollback history buffer.
> -i            Interrupt output sooner when flow control is on.
> -l            Login mode on (update /var/run/utmp), -ln = off.
> -ls [match]   or
> -list         Do nothing, just list our SockDir [on possible matches].
> -L            Turn on output logging.
> -m            ignore $STY variable, do create a new screen session.
> -O            Choose optimal output rather than exact vt100 emulation.
> -p window     Preselect the named window if it exists.
> -q            Quiet startup. Exits with non-zero return code if unsuccessful.
> -Q            Commands will send the response to the stdout of the querying process.
> -r [session]  Reattach to a detached screen process.
> -R            Reattach if possible, otherwise start a new session.
> -s shell      Shell to execute rather than $SHELL.
> -S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
> -t title      Set title. (window's name).
> -T term       Use term as $TERM for windows, rather than "screen".
> -U            Tell screen to use UTF-8 encoding.
> -v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
> -wipe [match] Do nothing, just clean up SockDir [on possible matches].
> -x            Attach to a not detached screen. (Multi display mode).
> -X            Execute <cmd> as a screen command in the specified session.

И пример .screenrc файл:

$ cat .screenrc
#
# Example of a user's .screenrc file
#

# This is how one can set a reattach password:
# password ODSJQf.4IJN7E    # "1234"

# no annoying audible bell, please
vbell on

# detach on hangup
autodetach on

# don't display the copyright page
startup_message off

# emulate .logout message
pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended."

# advertise hardstatus support to $TERMCAP
# termcapinfo  * '' 'hs:ts=\E_:fs=\E\\:ds=\E_\E\\'

# make the shell in every window a login shell
#shell -$SHELL

# autoaka testing
# shellaka '> |tcsh'
# shellaka '$ |sh'

# set every new windows hardstatus line to somenthing descriptive
# defhstatus "screen: ^En (^Et)"

defscrollback 1000

# don't kill window after the process died
# zombie "^["

################
#
# xterm tweaks
#

#xterm understands both im/ic and doesn't have a status line.
#Note: Do not specify im and ic in the real termcap/info file as
#some programs (e.g. vi) will not work anymore.
termcap  xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l
terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l

#80/132 column switching must be enabled for ^AW to work
#change init sequence to not switch width
termcapinfo  xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l

# Make the output buffer large for (fast) xterms.
termcapinfo xterm* OL=10000

# tell screen that xterm can switch to dark background and has function
# keys.
termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l'
termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'
termcapinfo xterm 'kh=\E[1~:kI=\E[2~:kD=\E[3~:kH=\E[4~:kP=\E[H:kN=\E[6~'

# special xterm hardstatus: use the window title.
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]0;screen\007'

# our xterm has colors! (rxvt, too)
termcap  xterm 'AF=\E[3%dm:AB=\E[4%dm'
terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm'

#terminfo xterm 'vb=\E[?5h$<200/>\E[?5l'
termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l'

# emulate part of the 'K' charset
termcapinfo   xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337'

# xterm-52 tweaks:
# - uses background color for delete operations
# - maps F1-4 to PF1-4
# termcapinfo xterm ut
# termcapinfo xterm 'k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS'

################
#
# wyse terminals
#

#wyse-75-42 must have flow control (xo = "terminal uses xon/xoff")
#essential to have it here, as this is a slow terminal.
termcapinfo wy75-42 xo:hs@

# New termcap sequences for cursor application mode.
termcapinfo wy* CS=\E[?1h:CE=\E[?1l:vi=\E[?25l:ve=\E[?25h:VR=\E[?5h:VN=\E[?5l:cb=\E[1K:CD=\E[1J

################
#
# other terminals
#

#make hp700 termcap/info better
termcapinfo  hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@'

# Extend the vt100 desciption by some sequences.
termcap  vt100* ms:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC
terminfo vt100* ms:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC


################
#
# keybindings
#

#remove some stupid / dangerous key bindings
bind k
bind ^k
bind .
bind ^\
bind \\
#bind ^h
bind h
#make them better
bind '\\' quit
bind 'K' kill
bind 'I' login on
bind 'O' login off
bind '}' history

# Yet another hack:
# Prepend/append register [/] to the paste if ^a^] is pressed.
# This lets me have autoindent mode in vi.
register [ "\033:se noai\015a"
register ] "\033:se ai\015a"
bind ^] paste [.]

################
#
# default windows
#

# screen -t local 0
# screen -t mail 1 elm
# screen -t 40 2 rlogin faui40

# yeah, please don't re-map the screen ESCAPE char 
#  there could be wailing and gNasHing of teeth
#  anyway this is how you would do it if you were a cRaZy loOpeR:
#escape ^Zz

Это не ~quite ~ точно ответ на вопрос, который задают.

Но это - на самом деле ответ, который Вы искали!> ;-)

screen очень полезно.

Развлекайтесь!

James.

0
ответ дан 23 November 2017 в 02:28

Другие вопросы по тегам:

Похожие вопросы: