```text
__ __ _ _ _
| \/ | ___ __| | ___ _ __ _ __ | (_)_ __ _ ___ __
| |\/| |/ _ \ / _` |/ _ \ '__| '_ \ | | | '_ \| | | \ \/ /
| | | | (_) | (_| | __/ | | | | | | | | | | | |_| |> <
|_| |_|\___/ \__,_|\___|_| |_| |_| |_|_|_| |_|\__,_/_/\_\
_ _ _ _
___| (_) | |_ ___ ___ | |___
/ __| | | | __/ _ \ / _ \| / __|
| (__| | | | || (_) | (_) | \__ \
\___|_|_| \__\___/ \___/|_|___/
```
---
## Target audience
- linux desktop CLI users
- linux admins
```text
__________________________________________
/ This is the year of linux on the desktop \
| |
| ...Windows10 has WSL ;-) |
\ /
------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
---
## Linux tooling philosophy
- **do one thing (and only one thing!) well**
- **chaining**
- _sound familiar? (hint: functional programming...)_
---
## Why? Improvements to...
- **productivity**
- **optics**
- "unix porn" (`PS1`, `ls`, ...)
---
## Learn the basics
- `emacs` and `vim`
- learn navigation, copy & paste, (and how to exit 👍)
- pick one and become fluent
- `cd`, `ls`, `cat`, `less`, `find`, `grep`, `sed`, `tail`, `awk`, `dd`, `rsync`, ...
- Combine using pipes ( `|` ) and redirection ( `>` )
---
## terminals and shells
### What is the difference between **terminal** and **shell**?
```text
+--------------------+
| "terminal" |
+--------------------+
| |
| +--------------+ |
| | | |
| | "shell" | |
| | | |
| +--------------+ |
| |
+--------------------+
```
--
## terminals and shells
### terminal
- **colors** (16 or more), **fonts** (utf8, ligatures, ...)
- **interactions**
- keyboard shortcuts
- mouse interaction (copy & paste, scrolling, selection, ...)
### shell
- **everything else** (f.ex. **`PS1`**, scripting language)
--
## terminal
### What is the best terminal?
- use your default
### Unicode, Emojis, Fonts, Image support (!)
- but think about enriching your output!
- Emojis: 👍 ✅ 💥 ✌ 💩 💬 🌩 🌟
---
## shell
- bash
- zsh
- fish
- dash (embedded)
--
### shell / zsh
- https://www.zsh.org/
- package manager
- oh-my-zsh (151k stars) https://ohmyz.sh
- category: shell
--
### shell / fish: The new kid on the block
- https://fishshell.com
- package manager
- fisher (6.1k stars) https://github.com/jorgebucaran/fisher
- oh-my-fish (8.8k stars) https://github.com/oh-my-fish/oh-my-fish
- category: shell
--
### shell / bash
- https://www.gnu.org/software/bash/
- package manager
- bash-it (13.2k stars) https://github.com/Bash-it/bash-it
- oh-my-bash (3.5k stars) https://ohmybash.github.io
- category: shell
---
### shell / PS1
PS1: alias for "prompt"
- default: `username:/some/location$`
- `$PWD` present working directory
Extra, nice-to-have information
- only show relevant parts (hide user/machine name on local machine)
- compact location ( $PWD )
- git status
- environment infos (node / .NET / Java / Python / etc version)
--
### shell / PS1: liquidprompt
simple prompt
- 4.2k stars https://github.com/nojhan/liquidprompt
- shortens `$PWD`
- adds git status
- available for `zsh`, `bash`, etc
- category: unix-porn
--
### shell / PS1: Powerline
started as fancy statusline for vim …
- 11k stars https://github.com/powerline/powerline
- started as fancy statusline for `vim`...
- shortens `$PWD`
- adds git status
- available for `zsh`, `bash`, etc
- category: unix-porn
--
### shell / PS1: Starship
the new kid on the block
- 16k stars https://github.com/starship/starship
- cross-plattform, cross-shell
- stylish
- great defaults for many environments
- easy to [configure](https://starship.rs/config/)
- category: unix-porn
---
# [Command-Line Operators and What They Do](https://www.makeuseof.com/linux-command-line-chaining-operators/)
--
## Ampersand Operator (&)
```bash
$ sleep 5 &
[1] 301161
```
- command is executed in the background
- shell is freed
--
## Semicolon Operator (;)
```bash
$ pwd; mkdir /tmp/test; cd /tmp/test; touch foo; readlink -f foo
/tmp
/tmp/test/foo
```
- chaining execute commands in a defined, sequential order
- independend from exit code
--
## OR Operator (||)
```bash
$ false || uptime
11:21:53 up 20 days, 2:30, 1 user, load average: 0,36, 0,35, 0,46
```
- following command only executed if preceding command fails (exit 0)
--
## Pipe Operator (|)
```bash
$ lspci | grep -E "(Network|Ethernet)"
00:14.3 Network controller: Intel Corporation Comet Lake PCH-LP CNVi WiFi
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (10) I219-V
```
- directs output of preceding command as input to succeeding command
--
## AND Operator (&&)
```bash
$ pwd && mkdir /tmp/test && cd /tmp/test && touch foo && readlink -f foo
/tmp/test
mkdir: cannot create directory '/tmp/test': File exists
$ pwd && mkdir -p /tmp/test && cd /tmp/test && touch foo && readlink -f foo
/tmp/test
/tmp/test/foo
```
- following command only executed if preceding command was successfully executed (exit 1)
--
## NOT Operator (!)
```bash
$ ls !(*.txt)
foo
```
- works similar to except statement in programming
--
## Precedence Operator ((..))
```bash
$ (true && false) && (false || true) || echo "Did exit with false"
Did exit with false
```
- used for grouping and precedence of the execution sequence
- inside parentheses, starts [subshell](https://tldp.org/LDP/abs/html/subshells.html#SUBSHELLSREF)
--
## Combination Operator ({..})
```bash
$ [ -f hello.txt ] && echo "file exists" ; echo "hello"
hello
$ [ -f hello.txt ] && { echo "file exists" ; echo "hello"; }
```
- commands are run (or not run) as a whole
--
## Concatenation or the Escape Operator (\\)
```bash
$ echo "Hello! from the\
> other side"
Hello! from theother side
$ touch test\(1\).txt
$ ls test\(1\).txt
'test(1).txt'
```
- concatenate large commands over several lines
- escape character when working with strings
--
## Redirection Operators (>, >>, <)
```bash
$ echo "dsd" > test; echo "bssss" >> test; cat test
dsd
bssss
$ sort < test
bssss
dsd
$ echo "blah" > test; cat test
blah
```
- redirect [stdout](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) or [stdin](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin))
- Use `2>` to handle [sterr](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr))
--
## References
- [10 Linux Command-Line Operators and What They Do](https://www.makeuseof.com/linux-command-line-chaining-operators/)
- [Chaining Commands in Linux](https://www.geeksforgeeks.org/chaining-commands-in-linux/)
- [Basics on bash operators](https://lumian2015.github.io/MoreOnLinux/chapter1.html)
- [10 Useful Chaining Operators in Linux with Practical Examples](https://www.tecmint.com/chaining-operators-in-linux-with-practical-examples/)
- [6 Bash Shell Command Line Chaining Operators in Linux](https://www.thegeekdiary.com/6-bash-shell-command-line-chaining-operators-in-linux/)
---
# Tools
## You where waiting for
--
## tldr
- 41k stars https://tldr.sh/
- man pages can be difficult
- tldr: implemented in many languages (js, ruby, python, perl, haskell, etc)
- Demo: `ln`, `tar`, `scp`
--
## McFly
- 4.5 stars https://github.com/cantino/mcfly
- category: history search
> McFly replaces your default `Ctrl R` shell history search with an intelligent search engine that takes into account your working
directory and the context of recently executed commands. McFly’s suggestions are prioritized in real time with a small neural network
--
## thefuck
fix common typos / mistakes
- 51k stars https://github.com/nvbn/thefuck
- example: pushing a newly created git branch
- category: productivity
--
### The GNU Midnight Commander
[mc](http://midnight-commander.org/) is a visual shell much like a file manager, only with many more features
- text mode application, but it also includes mouse support
- best [features](https://www.uibk.ac.at/th-physik/howto/mc.html) are its ability to FTP, view tar and zip files, and to poke into tar, ar, deb, zip, cpio, lha and rar for specific files
--
## bat
`cat` & `less` with syntax highlighting
- 37.6k stars https://github.com/sharkdp/bat
_bat looks good on a dark background by default. However, if your terminal uses a light background, some themes like GitHub or OneHalfLight will work better for you._
- category: read / file display
--
## ripgrep
very fast `grep` replacement
- 33.7k stars https://github.com/BurntSushi/ripgrep
- `ripgrep` recursively searches directories for a regex pattern
- sensible defaults: respect `.gitignore`, ignores hidden files & folders
- command: `rg`
- use `rg hidden g '!.git' "your search"` to search all hidden folder except .git
- category: search
--
## ripgrep-all
ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, sqlite (!), etc
- 5k stars https://github.com/phiresky/ripgrep-all
- command: `rga`
- faster than `pdfgrep` (see website for a benchmark)
- category: search
- Demo: search in Manning books folder
--
## fzf
interactive fuzzy search
- 47.5k stars https://github.com/junegunn/fzf
- pipe any line based input to fzf: Example `find * -type f | fzf`
- good integration with other tools
- nice helper methods for
- files & directories `cd **