From b60bd5d6313952c2f3372e286a67087dd61ce89c Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Fri, 16 Jun 2023 02:25:05 +0200 Subject: [PATCH] edit shells slides --- slides/shells/shells.md | 70 ++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/slides/shells/shells.md b/slides/shells/shells.md index 0ceeee2..3befb9d 100644 --- a/slides/shells/shells.md +++ b/slides/shells/shells.md @@ -2,30 +2,28 @@ - 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 | -| `#!/bin/fish` | madness | -| `#!/bin/elvish`| genius | +| 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 | 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) -- 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