added section on mutlitarget paths
This commit is contained in:
37
docs/bash.md
37
docs/bash.md
@@ -1,6 +1,14 @@
|
|||||||
# bash
|
# bash
|
||||||
|
|
||||||
## shortcut list
|
- [bash](#bash)
|
||||||
|
- [shortcuts](#shortcuts)
|
||||||
|
- [list of shortcuts](#list-of-shortcuts)
|
||||||
|
- [unbind shortcuts](#unbind-shortcuts)
|
||||||
|
- [tips and tricks](#tips-and-tricks)
|
||||||
|
- [multitarget paths](#multitarget-paths)
|
||||||
|
|
||||||
|
## shortcuts
|
||||||
|
### list of shortcuts
|
||||||
| Shortcut | Action |
|
| Shortcut | Action |
|
||||||
| :--------- | :----- |
|
| :--------- | :----- |
|
||||||
| ctrl+a | go to the start of the line |
|
| ctrl+a | go to the start of the line |
|
||||||
@@ -9,9 +17,9 @@
|
|||||||
| ctrl+f | move one character forwards |
|
| ctrl+f | move one character forwards |
|
||||||
| alt+b | move one word backwards |
|
| alt+b | move one word backwards |
|
||||||
| alt+f | move one word forwards |
|
| alt+f | move one word forwards |
|
||||||
| **ctrl+w** | delete to last white space |
|
| **ctrl+w** | **delete to last white space** |
|
||||||
| alt+? | show completion options |
|
| alt+? | show completion options |
|
||||||
| **ctrl+r** | search command history backwards |
|
| **ctrl+r** | **search command history backwards** |
|
||||||
| ctrl+g | exit history search |
|
| ctrl+g | exit history search |
|
||||||
| ctrl+p | previous command in history |
|
| ctrl+p | previous command in history |
|
||||||
| ctrl+n | next command in history |
|
| ctrl+n | next command in history |
|
||||||
@@ -21,9 +29,9 @@
|
|||||||
| ctrl+q | resume output to screen |
|
| ctrl+q | resume output to screen |
|
||||||
| ctrl+c | terminate command |
|
| ctrl+c | terminate command |
|
||||||
| ctrl+z | suspend current command (resume with `fg`) |
|
| ctrl+z | suspend current command (resume with `fg`) |
|
||||||
| **ctrl+d** | exit shell |
|
| **ctrl+d** | **exit shell** |
|
||||||
|
|
||||||
## unbind shortcuts
|
### unbind shortcuts
|
||||||
bash shortcuts can be disabled with the following command in `.bashrc`/`.bash_profile`:
|
bash shortcuts can be disabled with the following command in `.bashrc`/`.bash_profile`:
|
||||||
```bash
|
```bash
|
||||||
bind -r "<shortcut-to-unbind>"
|
bind -r "<shortcut-to-unbind>"
|
||||||
@@ -33,3 +41,22 @@ Example:
|
|||||||
bind -r "\C-h"
|
bind -r "\C-h"
|
||||||
```
|
```
|
||||||
`\C` is CTRL, `\M` is ALT
|
`\C` is CTRL, `\M` is ALT
|
||||||
|
|
||||||
|
## tips and tricks
|
||||||
|
|
||||||
|
### multitarget paths
|
||||||
|
|
||||||
|
Bash allows for variable expansion in paths. This can be useful, for example when copying multiple files from a directory. Instead of typing out the path multiple times, one can use '{<>,<>}' to specify multiple targets:
|
||||||
|
```bash
|
||||||
|
# without multitarget expansion
|
||||||
|
cp foo/bar/moo.wav foo/bar/bark.wav foo/
|
||||||
|
|
||||||
|
# with multitarget expansion
|
||||||
|
cp foo/bar/{moo.wav,bark.wav} foo/
|
||||||
|
|
||||||
|
# or even
|
||||||
|
cp foo/bar/{moo,bark}.wav foo/
|
||||||
|
```
|
||||||
|
Multitarget expansion also works in the middle of a path as seen in the third command example above.
|
||||||
|
> Use only ',' to separate targets and **no whitespace** as that would make a new argument.
|
||||||
|
> The expansion makes a new argument for each entry inside the braces, so **copy to several targets does not work.**
|
||||||
|
|||||||
Reference in New Issue
Block a user