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