OSDN Git Service

Regular updates
[twpd/master.git] / zsh.md
1 ---
2 title: zsh
3 category: CLI
4 layout: 2017/sheet
5 ---
6
7 ### Expressions
8
9 | Expression        | Example             | Description
10 | ---               | ---                 | ---
11 | `!!`              | `sudo !!`           | Last command (`sudo !!`)
12 | ---               | ---                 | ---
13 | `!*`              | `vim !*`            | Last command's parameters (`vim !*`)
14 | `!^`              |                     | Last command's first parameter
15 | `!$`              |                     | Last command's last parameter
16 | ---               | ---                 | ---
17 | `!?ls` `<tab>`    | `sudo !?mv` `<tab>` | Command and params of last `ls` command
18 | `!?ls?:*` `<tab>` |                     | Params of last `ls` command
19 | ---               | ---                 | ---
20 | `*(m0)`           | `rm *(m0)`          | Last modified today
21 | `*(m-4)`          |                     | Last modified <4 days ago
22 {: .-headers}
23
24 ### Change default shell
25
26 ```bash
27 chsh -s `which zsh`
28 ```
29
30 ### Process Substitution
31
32 | Expression        | Example                                               | Description
33 | ---               | ---                                                   | ---
34 | `<(COMMAND)`      | `grep "needle" <(curl "https://haystack.io")`         | Replace argument with _named pipe/FIFO_ (read-only) with command output
35 | `=(COMMAND)`      | `vim =(curl "https://haystack.io")`                   | Replace argument with _file_ (writable) containing command output
36 {: .-headers}
37
38 ### Also see
39
40 - [Bash cheatsheet](./bash)
41
42 Zsh is mostly compatible with Bash, so most everything in Bash's cheatsheet also applies.