mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-23 21:27:00 +00:00
Compare commits
17 Commits
671c0eb16f
...
3e6bbf7c20
Author | SHA1 | Date | |
---|---|---|---|
|
3e6bbf7c20 | ||
|
29902039d8 | ||
|
b6ff5a9fcc | ||
|
1c5bd35608 | ||
|
6054869173 | ||
|
a67ee7e167 | ||
|
58b858888a | ||
|
9ae2d9403b | ||
|
55fc47b685 | ||
|
ca89df83dc | ||
|
1b42d476e4 | ||
|
5d5b83b7b8 | ||
|
5f0c40efc5 | ||
|
57085df9be | ||
|
7d1c903031 | ||
|
a59f19e9cf | ||
|
c3a29f735a |
83
README.md
83
README.md
@ -33,22 +33,23 @@ Here's a more stylish version of [Bash-Oneliner](https://onceupon.github.io/Bash
|
|||||||
|
|
||||||
##### Using Ctrl keys
|
##### Using Ctrl keys
|
||||||
```
|
```
|
||||||
|
Ctrl + a : move to the beginning of line.
|
||||||
|
Ctrl + d : if you've type something, Ctrl + d deletes the character under the cursor, else, it escapes the current shell.
|
||||||
|
Ctrl + e : move to the end of line.
|
||||||
|
Ctrl + k : delete all text from the cursor to the end of line.
|
||||||
|
Ctrl + l : equivalent to clear.
|
||||||
Ctrl + n : same as Down arrow.
|
Ctrl + n : same as Down arrow.
|
||||||
Ctrl + p : same as Up arrow.
|
Ctrl + p : same as Up arrow.
|
||||||
|
Ctrl + q : to resume output to terminal after Ctrl + s.
|
||||||
Ctrl + r : begins a backward search through command history.(keep pressing Ctrl + r to move backward)
|
Ctrl + r : begins a backward search through command history.(keep pressing Ctrl + r to move backward)
|
||||||
Ctrl + s : to stop output to terminal.
|
Ctrl + s : to stop output to terminal.
|
||||||
Ctrl + q : to resume output to terminal after Ctrl + s.
|
|
||||||
Ctrl + a : move to the beginning of line.
|
|
||||||
Ctrl + e : move to the end of line.
|
|
||||||
Ctrl + d : if you've type something, Ctrl + d deletes the character under the cursor, else, it escapes the current shell.
|
|
||||||
Ctrl + k : delete all text from the cursor to the end of line.
|
|
||||||
Ctrl + x + backspace : delete all text from the beginning of line to the cursor.
|
|
||||||
Ctrl + t : transpose the character before the cursor with the one under the cursor, press Esc + t to transposes the two words before the cursor.
|
Ctrl + t : transpose the character before the cursor with the one under the cursor, press Esc + t to transposes the two words before the cursor.
|
||||||
Ctrl + w : cut the word before the cursor; then Ctrl + y paste it
|
|
||||||
Ctrl + u : cut the line before the cursor; then Ctrl + y paste it
|
Ctrl + u : cut the line before the cursor; then Ctrl + y paste it
|
||||||
Ctrl + _ : undo typing.
|
Ctrl + w : cut the word before the cursor; then Ctrl + y paste it
|
||||||
Ctrl + l : equivalent to clear.
|
Ctrl + x + backspace : delete all text from the beginning of line to the cursor.
|
||||||
Ctrl + x + Ctrl + e : launch editor defined by $EDITOR to input your command. Useful for multi-line commands.
|
Ctrl + x + Ctrl + e : launch editor defined by $EDITOR to input your command. Useful for multi-line commands.
|
||||||
|
Ctrl + z : stop current running process and keep it in background. You can use `fg` to continue the process in the foreground, or `bg` to continue the process in the background.
|
||||||
|
Ctrl + _ : undo typing.
|
||||||
```
|
```
|
||||||
##### Change case
|
##### Change case
|
||||||
```bash
|
```bash
|
||||||
@ -59,6 +60,7 @@ Esc + l
|
|||||||
Esc + c
|
Esc + c
|
||||||
# converts letter under the cursor to uppercase, rest of the word to lowercase.
|
# converts letter under the cursor to uppercase, rest of the word to lowercase.
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Run history number (e.g. 53)
|
##### Run history number (e.g. 53)
|
||||||
```bash
|
```bash
|
||||||
!53
|
!53
|
||||||
@ -129,6 +131,31 @@ $USER current username
|
|||||||
$HOSTNAME current hostname
|
$HOSTNAME current hostname
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Using vi-mode in your shell
|
||||||
|
```bash
|
||||||
|
set -o vi
|
||||||
|
# change bash shell to vi mode
|
||||||
|
# then hit the Esc key to change to vi edit mode (when `set -o vi` is set)
|
||||||
|
k
|
||||||
|
# in vi edit mode - previous command
|
||||||
|
j
|
||||||
|
# in vi edit mode - next command
|
||||||
|
0
|
||||||
|
# in vi edit mode - beginning of the command
|
||||||
|
R
|
||||||
|
# in vi edit mode - replace current characters of command
|
||||||
|
2w
|
||||||
|
# in vi edit mode - next to 2nd word
|
||||||
|
b
|
||||||
|
# in vi edit mode - previous word
|
||||||
|
i
|
||||||
|
# in vi edit mode - go to insert mode
|
||||||
|
v
|
||||||
|
# in vi edit mode - edit current command in vi
|
||||||
|
man 3 readline
|
||||||
|
# man page for complete readline mapping
|
||||||
|
```
|
||||||
|
|
||||||
## Variable
|
## Variable
|
||||||
[[back to top](#handy-bash-one-liners)]
|
[[back to top](#handy-bash-one-liners)]
|
||||||
##### Variable substitution within quotes
|
##### Variable substitution within quotes
|
||||||
@ -144,7 +171,7 @@ echo '$foo'
|
|||||||
# single quotes within double quotes will not cancel expansion and will be part of the output
|
# single quotes within double quotes will not cancel expansion and will be part of the output
|
||||||
echo "'$foo'"
|
echo "'$foo'"
|
||||||
# 'bar'
|
# 'bar'
|
||||||
# doubled single quotes act as double quotes making variables expand
|
# doubled single quotes act as if there are no quotes at all
|
||||||
echo ''$foo''
|
echo ''$foo''
|
||||||
# bar
|
# bar
|
||||||
```
|
```
|
||||||
@ -2074,11 +2101,6 @@ killall pulseaudio
|
|||||||
# then press Alt-F2 and type in pulseaudio
|
# then press Alt-F2 and type in pulseaudio
|
||||||
```
|
```
|
||||||
|
|
||||||
##### When sound not working
|
|
||||||
```bash
|
|
||||||
killall pulseaudio
|
|
||||||
```
|
|
||||||
|
|
||||||
##### List information about SCSI devices
|
##### List information about SCSI devices
|
||||||
```bash
|
```bash
|
||||||
lsscsi
|
lsscsi
|
||||||
@ -3144,11 +3166,40 @@ rsync -av directory user@ip_address:/path/to/directory.bak
|
|||||||
# skip files that are newer on receiver (i prefer this one!)
|
# skip files that are newer on receiver (i prefer this one!)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Create a temporary directory and `cd` into it
|
||||||
|
```bash
|
||||||
|
cd $(mktemp -d)
|
||||||
|
# for example, this will create a temporary directory "/tmp/tmp.TivmPLUXFT"
|
||||||
|
```
|
||||||
|
|
||||||
##### Make all directories at one time!
|
##### Make all directories at one time!
|
||||||
```bash
|
```bash
|
||||||
mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat}
|
mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat}
|
||||||
# -p: make parent directory
|
# -p: make parent directory
|
||||||
# this will create project/doc/html/; project/doc/info; project/lib/ext ,etc
|
# this will create:
|
||||||
|
# project/
|
||||||
|
# project/bin/
|
||||||
|
# project/demo/
|
||||||
|
# project/demo/stat/
|
||||||
|
# project/doc/
|
||||||
|
# project/doc/html/
|
||||||
|
# project/doc/info/
|
||||||
|
# project/doc/pdf/
|
||||||
|
# project/lib/
|
||||||
|
# project/lib/ext/
|
||||||
|
# project/src/
|
||||||
|
#
|
||||||
|
# project/
|
||||||
|
# ├── bin
|
||||||
|
# ├── demo
|
||||||
|
# │ └── stat
|
||||||
|
# ├── doc
|
||||||
|
# │ ├── html
|
||||||
|
# │ ├── info
|
||||||
|
# │ └── pdf
|
||||||
|
# ├── lib
|
||||||
|
# │ └── ext
|
||||||
|
# └── src
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Run command only if another command returns zero exit status (well done)
|
##### Run command only if another command returns zero exit status (well done)
|
||||||
|
Loading…
Reference in New Issue
Block a user