= configuración/uso screen
== install & help
* sudo apt install screen
* [[https://linuxize.com/post/how-to-use-linux-screen/]]
* [[https://www.gnu.org/software/screen/manual/screen.html]]
* versión moderna TMUX: [[https://www.howtogeek.com/671422/how-to-use-tmux-on-linux-and-why-its-better-than-screen/]]
== comando
* ''screeen -ls'': lista sesiones
* ''screen -r []'' : retornar a última sesión o a sesión específica
* ''screen -S '': añade a la sesión (descriptivo)
* ''screen -d'': cerrar sesión
* ''screen -U'': UTF-8 (zsh + agnoster)
* ''screen -dmS '': lanza en background
* ''screen -x -r '': acceso compartido a sessión attached
== shortcuts
(todas las letras en minúsculas excepto las negritas)
* C+a, d: deja la ejecución en segundo plano
* C+a, **a**: poner nombre a la consola actual (A mayúscula)
* C+a, x: Proteger con la contraseña del usuario de la sesión.
* C+a o C+a, k: salir de consola
=== split
* C+a, **s**: crear división horizontal (S en mayúscula)
* crear con C+a, c
* C+a, |: crear división vertical
* C+a, **x** : eliminar división (X en mayúscula)
=== move
* C+a, c: nueva consola virtual dentro del mismo screen
* C+a, p o n: ir a siguiente y anterior consola
* C+a, : ir a número de consola
* C+a, ": mostrar lista de consolas abiertas
=== log
* C+a, h: captura de pantalla (txt)
* C+a, **H**: logging de la sesión (txt) <- H mayúscula!
=== más...
{{ :linux:debian:seedbox:pasted:20230525-222144.png }}
/via: [[http://www.pixelbeat.org/lkdb/screen.html]]
== .screenrc
fichero de configuración en ''~/.screenrc''
# Bind F11 and F12 (NOT F1 and F2) to previous and next screen window
#bindkey -k F1 prev
#bindkey -k F2 next
# Also for ctrl-alt right and left arrows
# Note disable in window manager to allow through
bindkey ^[[1;7D prev
bindkey ^[[1;7C next
startup_message off
# Disable visual bell
vbell off
# Window list at the bottom.
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
#hardstatus string "%-w%{= BW}%50>%n %t%{-}%+w%<"
# From Stephen Shirley
# Don't block command output if the terminal stops responding
# (like if the ssh connection times out for example).
nonblock on
# Allow editors etc. to restore display on exit
# rather than leaving existing text in place
altscreen on
# Enable 256-color mode when screen is started with TERM=xterm-256color
# Taken from: http://frexx.de/xterm-256-notes/
#
# Note that TERM != "xterm-256color" within a screen window. Rather it is
# "screen" or "screen-bce"
#
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
#termcapinfo xterm-256color 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# save more scrollback
defscrollback 30000
# Turn off the welcome message
startup_message off
# Disable visual bell
vbell off
# Set scrollback buffer to 10000
defscrollback 10000
# Customize the status line
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
startup_message off
hardstatus alwayslastline '%{= wk}%?%-Lw%?%{r}(%{k}%n*%f%t%?(%u)%?%{r})%{k}%?%+Lw%?%?%= %d-%m-%Y %c'
activity ''
* 1ª linea: evita msg informativo
* 2ª linea: barra informativa (te permite saber si estás en una screen
== ejemplo uso rtorrent
* ''screen -q -S rtorrent'' -> abre sesión rtorrent
* si se produce un error -> ''Cannot open your terminal '/dev/pts/1' - please check.'' corregir con ''chmod 777 /dev/pts/1''
* también ''screen -S rtorrent rtorrent''
* una vez abierta sesión, ejecutar el rtorrent
* para salir de la sesión y que continue abierta, CTRL+A, D
* para volver a una sesión ya abierta: ''screen -raAd rtorrent''
* para matar rtorrent: ''killall -9 -u $(whoami) rtorrent''
* si se atasca, eliminar ficheros de directorios .session (se perderá todo lo compartido, aunque no los ficheros descargados)
== ejemplos
#!/bin/bash
### screen -q -S rtorrent
#screen -S rtorrent rtorrent
screen -S rtorrent -fa -d -m rtorrent
#!/bin/bash
screen -raAd rtorrent