Je n'ai pas encore vu de sujet à ce propos, si jamais il existe déjà merci de me le faire savoir 😉 Je l'utilise depuis quelques mois, je le trouve indispensable, et j'aimerai que l'on se partage nos fichiers de configuration et nos bonnes astuces pour en améliorer l'ergonomie ! 😃
Pour ceux qui ne connaissent pas cette application excellente, voir par là :
http://doc.ubuntu-fr.org/screen
Screen (Gnu/Screen) est un utilitaire permettant d'ouvrir plusieurs terminaux dans une même console, de passer de l'un à l'autre et de les récupérer plus tard. Il offre d'autres services très utiles comme :
* La possibilité d'attacher et de détacher une session, pratique pour reprendre la main sur un irssi.
* La possibilité de partager un terminal avec un autre utilisateur, idéal pour aider un utilisateur distant.
Voici donc une capture d'écran d'une session de screen tournant sur mon EeePC :
Et mon fichier 'screenrc' :
# $Id: screenrc,v 1.15 2003/10/08 11:39:03 zal Exp $
#
# /etc/screenrc
#
# This is the system wide screenrc.
#
# You can use this file to change the default behavior of screen system wide
# or copy it to ~/.screenrc and use it as a starting point for your own
# settings.
#
# Commands in this file are used to set options, bind screen functions to
# keys, redefine terminal capabilities, and to automatically establish one or
# more windows at the beginning of your screen session.
#
# This is not a comprehensive list of options, look at the screen manual for
# details on everything that you can put in this file.
#
# ------------------------------------------------------------------------------
# SCREEN SETTINGS
# ------------------------------------------------------------------------------
escape ^ww
startup_message off
#nethack on
#defflow on # will force screen to process ^S/^Q
deflogin on
autodetach on
# turn visual bell on
vbell on
vbell_msg " Wuff ---- Wuff!! "
# define a bigger scrollback, default is 100 lines
defscrollback 1024
altscreen on
# ------------------------------------------------------------------------------
# SCREEN KEYBINDINGS
# ------------------------------------------------------------------------------
# KeyBindings
bindkey -k F1 kill # bind f11 to kill terminal
bindkey -k F2 quit # bind f12 to quit screen
bindkey ² prev # bind "²" to move to previous window
bindkey = next # bind "=" to move to next window
bindkey "^[q" prev
bindkey "^[w" next
# Remove some stupid / dangerous key bindings
bind ^k
#bind L
bind ^\
# Make them better
bind \\ quit
bind K kill
bind I login on
bind O login off
bind } history
# An example of a "screen scraper" which will launch urlview on the current
# screen window
#
#bind ^B eval "hardcopy_append off" "hardcopy -h $HOME/.screen-urlview" "screen urlview $HOME/.screen-urlview"
# ------------------------------------------------------------------------------
# TERMINAL SETTINGS
# ------------------------------------------------------------------------------
# The vt100 description does not mention "dl". *sigh*
termcapinfo vt100 dl=5\E[M
# turn sending of screen messages to hardstatus off
hardstatus on
# Set the hardstatus prop on gui terms to set the titlebar/icon title
termcapinfo xterm*|rxvt*|kterm*|terminator*|Eterm* hs:ts=\E]0;:fs=\007:ds=\E]0;\007
# use this for the hard status string
#change the hardstatus settings to give an window list at the bottom of the
#screen, with the time and date and with the current window highlighted
hardstatus alwayslastline
#hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}'
#hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
#hardstatus string "%{bk}%?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{bk}%?%+Lw%= %{mk}@ %H %{ck}%Y%{bk}-%{ck}%m%{bk}-%{ck}%d %{yk}%D %{gk}%c"
#hardstatus string "%{=b .r}%D %d/%m %{w}- %{r}%c%{w} || [%{g}@%H%{w}] %w %= %1` | %{b}%l%{w}"
#hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
#hardstatus string '%{= dW}[ %{dg}%H %{dW}][%{dc}%= %?%-Lw%?%{dy}(%{dW}%n*%f %t%?(%u)%?%{dy})%{= dc}%?%+Lw%?%?%= %{dW}][%{dM}%l%{dW}][%{dy} %m/%d %c %{dW}]'
#hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]%{=b C}[ %m/%d %c ]%{W}'
#hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
#hardstatus string "%{+b Rk}(%{-b g}$LOGNAME@%H%{+b R}) (%{-b g}%C %a%{+b R}) %{-b g} %n %t %h"
#hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}'
#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 '%{= kG}%{C}Screen: %{c}%{= kG}[%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{C} %d-%m %{W}%c %{g}]'
hardstatus string "%{= kG}%{g}[ %{B}$LOGNAME@%H%{g} ] [%= %{= kw}%?%-Lw%?%{B}<< %n*%f%t%?(%u)%? >>%{w}%?%+Lw%?%?%= %{g}] [ %{B}%c:%s%{g} ]"
# set these terminals up to be 'optimal' instead of vt100
termcapinfo xterm*|linux*|rxvt*|Eterm* OP
# Change the xterm initialization string from is2=\E[!p\E[?3;4l\E[4l\E>
# (This fixes the "Aborted because of window size change" konsole symptoms found
# in bug #134198)
termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
# To get screen to add lines to xterm's scrollback buffer, uncomment the
# following termcapinfo line which tells xterm to use the normal screen buffer
# (which has scrollback), not the alternate screen buffer.
#
#termcapinfo xterm|xterms|xs|rxvt ti@:te@
# Enable non-blocking mode to better cope with flaky ssh connections.
defnonblock 5
# ------------------------------------------------------------------------------
# STARTUP SCREENS
# ------------------------------------------------------------------------------
screen -t BASH1_EeePC 1 bash
screen -t BASH2_EeePC 2 bash
screen -t HTOP 3 htop
screen -t IFTOP 4 sudo iftop -i wlan0
screen -t SSH-1_Portable 5 ssh -XC serveur
screen -t SSH-2_Portable 6 ssh -XC serveur
screen -t SSH-3_Portable 7 ssh -XC serveur
select 1
J'utilise donc des raccourcis clavier perso pour passer d'un terminal à l'autre (suivant : "=" / précédent : "²"), pour tuer un terminal (f11), ou pour quitter screen (f12). L'avantage ? Les touches f11 et f12 ne sont pas utilisées (ou peu) par les applications en ligne de commandes, à la différence des touches f1 à f10 ...
Je me sers de "ctrl-w" au lieu de "ctrl-a", mais je ne trouve pas ça très pratique non plus. J'aimerai utiliser "ctrl-tab" par exemple, mais je n'ai pas réussi à trouver comment coder cette fonction ?
Voilà, j'ai fait le tour, à vous de jouer maintenant !!!
😉