mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-22 12:57:01 +00:00
Separating Screen and Tmux
This commit is contained in:
parent
66150d418f
commit
b8b130d661
136
README.md
136
README.md
@ -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
|
||||||
@ -2829,12 +2821,16 @@ select-layout even-vertical
|
|||||||
# or
|
# or
|
||||||
Ctrl+b, Alt+2
|
Ctrl+b, Alt+2
|
||||||
|
|
||||||
# Distribute horizontally (columns):
|
# Distribute horizontally (columns):
|
||||||
select-layout even-horizontal
|
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
|
||||||
@ -2883,15 +2879,15 @@ tree
|
|||||||
```
|
```
|
||||||
##### set up virtualenv(sandbox) for python
|
##### set up virtualenv(sandbox) for python
|
||||||
```bash
|
```bash
|
||||||
#1. install virtualenv.
|
# 1. install virtualenv.
|
||||||
sudo apt-get install virtualenv
|
sudo apt-get install virtualenv
|
||||||
#2. Create a directory (name it .venv or whatever name your want) for your new shiny isolated environment.
|
# 2. Create a directory (name it .venv or whatever name your want) for your new shiny isolated environment.
|
||||||
virtualenv .venv
|
virtualenv .venv
|
||||||
#3. source virtual bin
|
# 3. source virtual bin
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
#4. you can check check if you are now inside a sandbox.
|
# 4. you can check check if you are now inside a sandbox.
|
||||||
type pip
|
type pip
|
||||||
#5. Now you can install your pip package, here requirements.txt is simply a txt file containing all the packages you want. (e.g tornado==4.5.3).
|
# 5. Now you can install your pip package, here requirements.txt is simply a txt file containing all the packages you want. (e.g tornado==4.5.3).
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -2920,11 +2916,11 @@ echo -e ${D2B[255]}
|
|||||||
##### Wrap each input line to fit in specified width (e.g 4 integers per line)
|
##### Wrap each input line to fit in specified width (e.g 4 integers per line)
|
||||||
```bash
|
```bash
|
||||||
echo "00110010101110001101" | fold -w4
|
echo "00110010101110001101" | fold -w4
|
||||||
#0011
|
# 0011
|
||||||
#0010
|
# 0010
|
||||||
#1011
|
# 1011
|
||||||
#1000
|
# 1000
|
||||||
#1101
|
# 1101
|
||||||
```
|
```
|
||||||
##### Sort a file by column and keep the original order
|
##### Sort a file by column and keep the original order
|
||||||
```bash
|
```bash
|
||||||
|
Loading…
Reference in New Issue
Block a user