cheatsheets/zsh.md

42 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2013-10-14 02:36:58 +00:00
---
2017-10-20 10:14:34 +00:00
title: zsh
2015-11-24 05:02:17 +00:00
category: CLI
2012-03-16 06:14:31 +00:00
---
2017-10-20 10:14:34 +00:00
### Expressions
2012-03-16 06:14:31 +00:00
2017-10-20 10:22:32 +00:00
| Expression | Example | Description
| --- | --- | ---
| `!!` | `sudo !!` | Last command (`sudo !!`)
| --- | --- | ---
| `!*` | `vim !*` | Last command's parameters (`vim !*`)
| `!^` | | Last command's first parameter
| `!$` | | Last command's last parameter
| --- | --- | ---
| `!?ls` `<tab>` | `sudo !?mv` `<tab>` | Command and params of last `ls` command
| `!?ls?:*` `<tab>` | | Params of last `ls` command
| --- | --- | ---
| `*(m0)` | `rm *(m0)` | Last modified today
| `*(m-4)` | | Last modified <4 days ago
{: .-headers}
2012-03-16 06:14:31 +00:00
2017-10-20 10:14:34 +00:00
### Change default shell
2012-03-16 06:14:31 +00:00
2017-10-20 10:14:34 +00:00
```bash
chsh -s `which zsh`
```
2012-03-16 06:14:31 +00:00
2018-11-16 19:59:38 +00:00
### Process Substitution
| Expression | Example | Description
| --- | --- | ---
| `<(COMMAND)` | `grep "needle" <(curl "https://haystack.io")` | Replace argument with _named pipe/FIFO_ (read-only) with command output
| `=(COMMAND)` | `vim =(curl "https://haystack.io")` | Replace argument with _file_ (writable) containing command output
{: .-headers}
2017-10-20 10:14:34 +00:00
### Also see
2012-03-16 06:14:31 +00:00
2017-10-20 10:14:34 +00:00
- [Bash cheatsheet](./bash)
2012-03-16 06:14:31 +00:00
2017-10-20 10:14:34 +00:00
Zsh is mostly compatible with Bash, so most everything in Bash's cheatsheet also applies.