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). Then, you can get multiple displays of a session:
$ tmux attach-session -t sessionid
Enable mouse (useful to switch windows or select panes in tmux) :
$ tmux set-option -t sessionid -g mouse on
Moving a source pane into a target window:
$ tmux list-panes -a pouet:0.0: ... pouet:1.0: ... <- current one
# mv src pane 'pouet:1.0' to win 'pouet:0' $ tmux join-pane -t pouet:0
$ tmux list-panes -a pouet:0.0: ... pouet:0.1: ... <- current one
In order to reverse the 'join-pane' operation, use break-pane:
$ tmux list-panes -a pouet:0.0: ... pouet:0.1: ... <- current one
$ tmux break-pane # break src pane off its current window
$ tmux list-panes -a pouet:0.0: ... pouet:1.0: ... <- current one
Instead of moving an existing pane, you can use 'split-window' to create a new pane:
$ tmux list-panes -a pouet:0.0: ... pouet:1.0: ... <- current one
$ tmux split-window
$ tmux list-panes -a pouet:0.0: ... pouet:1.0: ... pouet:1.1: ... <- current one
If you want to reverse the prevous
$ tmux break-pane
Kill session:
$ tmux kill-session -t sessionid
Link a window in another section:
$ ...