edit shells slides

This commit is contained in:
Malin Freeborn 2023-06-16 02:25:05 +02:00
parent 51dbe77dee
commit b60bd5d631
Signed by: andonome
GPG Key ID: 52295D2377F4D70F

View File

@ -2,30 +2,28 @@
- Used as a 'shell' around a bare-ass kernel. - Used as a 'shell' around a bare-ass kernel.
- People once considered a basic shell user-friendly. - People once considered a basic shell user-friendly.
- Once worked as slow printing.
## Use Cases ## Use Cases
- It's crazy-fast - It's crazy-fast to write.
- Try deleting a file in Python. - Try deleting a file in Python.
- It's awful for any structured data.
## Form
- Big mess of binaries, wrapped together
- Janky mess
# Bangs! # Bangs!
Don't say `#!/bin/bash` if you don't mean it! Don't say `#!/bin/bash` if you don't mean it!
| Bang! | Apraisal | | Bang! | Apraisal |
|:---------------|:--------------| |:------------------------|:--------------|
| `#!/bin/bash` | reasonable | | `#!/bin/bash` | reasonable |
| `#!/bin/sh` | sensible | | `#!/bin/sh` | sensible |
| `#!/bin/dash` | bad idea | | `#!/bin/dash` | bad idea |
| `#!/bin/zsh` | risky | | `#!/bin/zsh` | risky |
| `#!/bin/ksh` | foolish | | `#!/bin/ksh` | foolish |
| `#!/usr/bin/env bash` | pathetic |
| `#!/bin/fish` | madness | | `#!/bin/fish` | madness |
| `#!/bin/elvish`| genius | | `#!/bin/elvish` | genius |
Protip: for a faster machine, make `sh` a link to `/bin/dash`. Protip: for a faster machine, make `sh` a link to `/bin/dash`.
@ -35,8 +33,9 @@ Protip: for a faster machine, make `sh` a link to `/bin/dash`.
## `ksh` (korn shell) ## `ksh` (korn shell)
- Can be posix compliant with effort. - made before `bash`
- vi mode by default. - `vi` mode by default (means you're a hacker)
- Can be posix compliant with effort
## `elvish` ## `elvish`
@ -46,13 +45,40 @@ Protip: for a faster machine, make `sh` a link to `/bin/dash`.
- Ctrl+n to search for command arguments - Ctrl+n to search for command arguments
- Ctrl+l to return to previous locations - Ctrl+l to return to previous locations
## Bash Advantages ## zsh
- `for x in 1..10`
# Bash Advantages
- Equality check with "==". - Equality check with "==".
* Dash cannot do `if [ $x == 3 ]; then echo y; fi` * Dash cannot do `if [ $x == 3 ]; then echo y; fi`
- `$RANDOM` - `$RANDOM`
- Dash cannot use `&>/dev/null` - Dash cannot use `&>/dev/null`
- No history - No history
- `$PROMPT_COMMAND`
## Lists
```
myList+=(*)
echo "${myList[0]}"
```
# Functions
```
function wotsa(){
def="$(curl -s dict://dict.org/define:$1: | \
grep -vP '^\d\d\d ')"
if [ "$def" = "" ]; then
echo no definition
else
echo "$def" | mdcat -p
fi
}
```
# Protips # Protips
@ -61,16 +87,22 @@ Protip: for a faster machine, make `sh` a link to `/bin/dash`.
"\C-x": glob-expand-word "\C-x": glob-expand-word
``` ```
- `set -e`
- `set -x`
- `set -o vi` - `set -o vi`
- Ctrl+d - Ctrl+d
- `type $whatevre` - `type $whatever`
- `.inputrc` - `.inputrc`
- `PS1=foo`
# Fun with Bash # Fun with Bash
- wifi_qr.sh - wifi_qr.sh
- clean.sh - clean.sh
- theme.sh - theme.sh
- notflix.sh
- clip.sh
- vidget.sh
# Zen Master Foo # Zen Master Foo