mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-24 05:36:59 +00:00
Compare commits
No commits in common. "3e6bbf7c2036ab6d3bca1cc72c0648d68960ff67" and "671c0eb16f2219a147d84814a885cd4831408531" have entirely different histories.
3e6bbf7c20
...
671c0eb16f
85
README.md
85
README.md
@ -33,23 +33,22 @@ Here's a more stylish version of [Bash-Oneliner](https://onceupon.github.io/Bash
|
||||
|
||||
##### 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 + 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 + s : to stop output to terminal.
|
||||
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 + u : cut the line before the cursor; then Ctrl + y paste it
|
||||
Ctrl + w : cut the word before the cursor; then Ctrl + y paste it
|
||||
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 + 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 + 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 + _ : undo typing.
|
||||
Ctrl + l : equivalent to clear.
|
||||
Ctrl + x + Ctrl + e : launch editor defined by $EDITOR to input your command. Useful for multi-line commands.
|
||||
```
|
||||
##### Change case
|
||||
```bash
|
||||
@ -60,7 +59,6 @@ Esc + l
|
||||
Esc + c
|
||||
# converts letter under the cursor to uppercase, rest of the word to lowercase.
|
||||
```
|
||||
|
||||
##### Run history number (e.g. 53)
|
||||
```bash
|
||||
!53
|
||||
@ -131,31 +129,6 @@ $USER current username
|
||||
$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
|
||||
[[back to top](#handy-bash-one-liners)]
|
||||
##### Variable substitution within quotes
|
||||
@ -171,7 +144,7 @@ echo '$foo'
|
||||
# single quotes within double quotes will not cancel expansion and will be part of the output
|
||||
echo "'$foo'"
|
||||
# 'bar'
|
||||
# doubled single quotes act as if there are no quotes at all
|
||||
# doubled single quotes act as double quotes making variables expand
|
||||
echo ''$foo''
|
||||
# bar
|
||||
```
|
||||
@ -2101,6 +2074,11 @@ killall pulseaudio
|
||||
# then press Alt-F2 and type in pulseaudio
|
||||
```
|
||||
|
||||
##### When sound not working
|
||||
```bash
|
||||
killall pulseaudio
|
||||
```
|
||||
|
||||
##### List information about SCSI devices
|
||||
```bash
|
||||
lsscsi
|
||||
@ -3166,40 +3144,11 @@ rsync -av directory user@ip_address:/path/to/directory.bak
|
||||
# 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!
|
||||
```bash
|
||||
mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat}
|
||||
# -p: make parent directory
|
||||
# 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
|
||||
# this will create project/doc/html/; project/doc/info; project/lib/ext ,etc
|
||||
```
|
||||
|
||||
##### Run command only if another command returns zero exit status (well done)
|
||||
|
Loading…
Reference in New Issue
Block a user