User Tools

Site Tools


Writing /net/www/auesnard/teaching/data/cache/c/c0e37653382f0a3bba77dea63aebe2c6.metadata failed
screen:index
Writing /net/www/auesnard/teaching/data/cache/b/b917139305956507b1746900fb337322.xhtml failed

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
screen:index [2018/09/21 13:54] orelscreen:index [2020/09/01 19:44] orel
Line 18: Line 18:
 Kill a remote screen session Kill a remote screen session
   $ screen -S sessionid -X quit   $ screen -S sessionid -X quit
 +
 +Launch several commands in several windows, but in the same session:
 +
 +  $ screen -S sessionid -t win1 -A -d -m bash
 +  $ screen -S sessionid -X screen -t win2 -A -d -m bash
 +  $ screen -ls sessionid
 +  
 +Reattach all windows (use "ctrl-a + w" to list all windows):
 +
 +  $ screen -r sessionid
 +
 +
 +Reattach a given window: ???
 +
 +Shortcuts:
 +
 +  * Ctrl+a d : detach
 +  * ...
 +
 +
  
 ===== TMUX Tips ===== ===== TMUX Tips =====
Line 35: Line 55:
 Start another window in this session: Start another window in this session:
  
-  $ tmux new-window -t sessionid -n win1 bash+  $ tmux new-window -t sessionid -n win1 bash  
  
 List windows and panes: List windows and panes:
Line 43: Line 63:
   $ tmux list-panes -t sessionid:   # list all panes in window 0 of session   $ tmux list-panes -t sessionid:   # list all panes in window 0 of session
      
-Attach session to the end user's terminal (tmux in foreground):+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   $ tmux attach-session -t sessionid
      
-Join / Break windows panes...+Enable mouse (useful to switch windows or select panes in tmux) :
  
-  $ tmux join -t qemunet:0 # ??? +  $ tmux set-option -t sessionid -g mouse on  
-  $ tmux break ...+   
 +Moving a source pane into a target window: 
 +   
 +  $ tmux list-panes -a 
 +    pouet:0.0: ..
 +    pouet:1.0: ...   <- current one
  
-Kill session:+  # mv src pane 'pouet:1.0' to win 'pouet:0' 
 +  $ tmux join-pane -t pouet:
  
-  $ tmux kill-session -t sessionid+  $ tmux list-panes -
 +    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
  
-Pipe a pane:+  $ tmux break-pane # break src pane off its current window
  
-  # In a first terminal: +  $ tmux list-panes -a 
-  $ tmux new-session -s sessionid bash +    pouet:0.0: ..
-  ...+    pouet:1.0: ...   <- current one 
 +    
 +Instead of moving an existing pane, you can use 'split-window' to create a new pane:
  
-  # In a second terminal: +  $ tmux list-panes -
-  $ rm -f /tmp/tmuxpipe ; mkfifo /tmp/tmuxpipe +    pouet:0.0... 
-  $ tmux pipe-pane -t sessionid:0.0 -O -o 'cat >> /tmp/tmuxpipe' +    pouet:1.0: ...   <current one
-  $ cat /tmp/tmuxpipe +
-  # ... +
-  $ tmux pipe-pane -t sessionid:0.-I -o 'cat < /tmp/tmuxpipe' +
-  $ echo coucou > /tmp/tmuxpipe+
  
-All together:+  $ tmux split-window
  
-  $ rm -f /tmp/fifo1 /tmp/fifo2 ; mkfifo /tmp/fifo1 ; mkfifo /tmp/fifo2   +  $ tmux list-panes -
-  $ gcc dpipe.c +    pouet:0.0: ... 
-  $ tmux pipe-pane -t sessionid:0.0 -I -O -o './a.out /tmp/fifo1 /tmp/fifo2' +    pouet:1.0: ... 
-  $ cat > /tmp/fifo2 & cat /tmp/fifo1 +    pouet:1.1: ...   <- current one
  
  
 +If you want to reverse the prevous
  
-Configure your session:+  $ tmux break-pane
  
-  $ tmux set-option -t sessionid -g default-shell /bin/bash  +Kill session:
-  # 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 kill-session -t sessionid 
-  $ 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 +Link a window/pane in another session (multiple display): 
-  $ 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 '+  $ tmux new-session -s pouet1 
 +  $ tmux new-session -s pouet2 
 +  $ tmux list-panes -
 +    pouet1:0.0: ... %0 (active) 
 +    pouet2:0.0: ... %1 (active) 
 +  $ tmux link-window -s pouet1:0.0 -t pouet2 
 +  $ tmux list-panes -
 +    pouet1:0.0: ... %0 (active) 
 +    pouet2:0.0: ... %1 (active) 
 +    pouet2:0.0: ... %0 (active) 
 +     
 +==== Useful Shortcuts ==== 
 + 
 +  * ctrl-b d => detach 
 +  * ctrl-b w => list windows and select it 
 +  * ctrl-b n => next window 
 +  * ctrl-b p => previous window 
 +  * ctrl-b # => go to window (select by number) 
 +  * ctrl-b ? => help 
 +  * ctrl-b c => new shell window 
 +  * ctrl-b x => kill current pane 
 + 
 +I use to rebind 'ctrl-b x' to kill current session (or server)like that: 
 + 
 +  tmux bind-key x kill-session   
 + 
 +  
 +If you want to list current tmux sessions: 
 + 
 +  tmux ls 
 +   
 +If you want to (re-)attach your session (assuming there is only one running session): 
 + 
 +  tmux a 
 +   
 +If you want to kill all...
  
 +  tmux kill-server
  
 +Enjoy!
screen/index.txt · Last modified: 2024/03/18 15:06 by 127.0.0.1