User Tools

Site Tools


screen:index

This is an old revision of the document!


Screen Tips

Launch command test.sh in screen (detached from the user's terminal)

$ screen -S sessionid -d -m  ./test.sh

List screen session

$ screen -ls

Attach a remote screen session to the user's terminal

$ screen -r sessionid

Attach to a not detached screen session (Multi display mode)

$ screen -x sessionid

Detach a “remote” screen session from the user's terminal

$ screen -d sessionid

Kill a remote screen session

$ screen -S sessionid -X quit

TMUX Tips

A tmux session can contain several windows and a tmux window can contain several panes (with a tiled layout for instance). The window ID of the window 'n' in session 'sessionid' is 'sessionid:n', and the pane ID of a pane 'k' in a window 'n' is 'sessonid:n.k'.

Start tmux server:

$ tmux start-server

Start a new session 'sessionid' and a first window in this session:

$ tmux new-session -s sessionid -n win0              # run an interactive shell in foreground
$ tmux new-session -s sessionid -n win0 ./test.sh    # run a command in foreground  
$ tmux new-session -d -s sessionid -n win0 ./test.sh # run a command in background (detached)

Start another window in this session:

$ tmux new-window -t sessionid -n win1 bash

List windows and panes:

$ tmux list-windows -t sessionid    # list all windows in session
$ tmux list-panes -s -t sessionid   # list all panes in session
$ tmux list-panes -t sessionid:0    # list all panes in window 0 of session

Attach session to the end user's terminal (tmux in foreground):

$ tmux attach-session -t sessionid

Join / Break windows / panes…

$ tmux join -t qemunet:0 # ???
$ tmux break ...

Kill session:

$ tmux kill-session -t sessionid

Pipe a pane:

$ while true; do date; sleep 1; done
$ ...
# In a second terminal
$ rm -f /tmp/tmuxpipe ; mkfifo /tmp/tmuxpipe
$ tmux pipe-pane -t sessionid:0.0 -o 'cat >> /tmp/tmuxpipe'
$ cat /tmp/tmuxpipe
# ...
$ tmux pipe-pane -t sessionid:0.0 -I -o 'cat < /tmp/tmuxpipe'
$ echo coucou > /tmp/tmuxpipe

Configure your session:

$ tmux set-option -t sessionid -g default-shell /bin/bash 
# enable to select panes/windows  with mouse (howewer, hold shift key, to copy/paste with mouse)
$ tmux set-option -t sessionid -g mouse on 
$ tmux set-option -g prefix C-b   # default prefix
$ tmux bind-key C-c kill-session  # press "C-b C-c" to kill session!
$ tmux set-window-option -g window-status-current-bg red
$ tmux set-option -g status-left ''
$ tmux set-option -g status-right '#[fg=colour233,bg=colour241,bold] %d/%m/%Y #[fg=colour233,bg=colour245,bold] %H:%M:%S '
screen/index.1537517468.txt.gz · Last modified: 2024/03/18 15:05 (external edit)