Separating Screen and Tmux

This commit is contained in:
I-Man Ng 2019-05-10 16:20:40 +08:00 committed by GitHub
parent 66150d418f
commit b8b130d661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

114
README.md
View File

@ -95,6 +95,17 @@ or
# run cat filename again # run cat filename again
``` ```
##### Some handy environment variables
```
$0 :name of shell or shell script.
$1, $2, $3, ... :positional parameters.
$# :number of positional parameters.
$? :most recent foreground pipeline exit status.
$- :current options set for the shell.
$$ :pid of the current shell (not subshell).
$! :is the PID of the most recent background command.
```
## Grep ## Grep
[[back to top](#handy-bash-oneliner-commands)] [[back to top](#handy-bash-oneliner-commands)]
@ -2649,15 +2660,6 @@ var=$((var+1))
``` ```
##### Some handy environment variables
$0 :name of shell or shell script.
$1, $2, $3, ... :positional parameters.
$# :number of positional parameters.
$? :most recent foreground pipeline exit status.
$- :current options set for the shell.
$$ :pid of the current shell (not subshell).
$! :is the PID of the most recent background command.
##### Clear the contents of a file (e.g. filename) ##### Clear the contents of a file (e.g. filename)
```bash ```bash
>filename >filename
@ -2742,80 +2744,70 @@ example:
q -d "," "select c3,c4,c5 from /path/to/file.txt where c3='foo' and c5='boo'" q -d "," "select c3,c4,c5 from /path/to/file.txt where c3='foo' and c5='boo'"
``` ```
##### Screen and tmux ##### Using Screen for multiple terminal sessions
create session and attach:
```bash ```bash
# Create session and attach:
screen screen
or
tmux
```
create detached session foo: # Create detached session foo:
```bash
screen -S foo -d -m screen -S foo -d -m
or
tmux new -s foo -d
```
detached session foo: # Detached session foo:
```bash
screen: ^a^d screen: ^a^d
or
tmux: ^bd
```
# List sessions:
list sessions:
```bash
screen -ls screen -ls
or
tmux ls
```
attach: # Attach last session:
```bash
screen -r screen -r
or
tmux attach
```
attach to session foo: # Attach to session foo:
```bash
screen -r foo screen -r foo
or
tmux attach -t foo # Kill session foo:
```
kill session foo:
```bash
screen -r foo -X quit screen -r foo -X quit
or
tmux kill-session -t foo # Scroll:
```
scroll:
(screen)
Hit your screen prefix combination (C-a / control+A), then hit Escape. Hit your screen prefix combination (C-a / control+A), then hit Escape.
Move up/down with the arrow keys (↑ and ↓). Move up/down with the arrow keys (↑ and ↓).
Redirect output of an already running process in screen: # Redirect output of an already running process in Screen:
(C-a / control+A), then hit 'H' (C-a / control+A), then hit 'H'
store screen output for screen: # Store screen output for Screen:
Ctrl+A, Shift+H Ctrl+A, Shift+H
You will then find a screen.log file under current directory. # You will then find a screen.log file under current directory.
```
(tmux) ##### Using Tmux for multiple terminal sessions
Ctrl-b then \[ then you can use your normal navigation keys to scroll around.
Press q to quit scroll mode.
Send command to all panes in tmux:
```bash ```bash
# Create session and attach:
tmux
# Attach to session foo:
tmux attach -t foo
# Detached session foo:
^bd
# List sessions:
tmux ls
# Attach last session:
tmux attach
# Kill session foo:
tmux kill-session -t foo
# Create detached session foo:
tmux new -s foo -d
# Send command to all panes in tmux:
Ctrl-B Ctrl-B
:setw synchronize-panes :setw synchronize-panes
```
Some tmux pane control commands:
```bash
Ctrl-B
# Some tmux pane control commands:
Ctrl-B
# Panes (splits), Press Ctrl+B, then input the following symbol: # Panes (splits), Press Ctrl+B, then input the following symbol:
# % horizontal split # % horizontal split
# " vertical split # " vertical split
@ -2834,7 +2826,11 @@ select-layout even-horizontal
# or # or
Ctrl+b, Alt+1 Ctrl+b, Alt+1
# Scroll
Ctrl-b then \[ then you can use your normal navigation keys to scroll around.
Press q to quit scroll mode.
``` ```
##### Cut the last column ##### Cut the last column
```bash ```bash
cat filename|rev|cut -f1|rev cat filename|rev|cut -f1|rev