CMD > snippets

· EOG, like EOF


Table of Contents

alias hd='sudo hdparm -Y /dev/sda'

² NTFY.sh #

f_ntfy (){ curl -d "$1" ntfy.sh/divienne ;}

.

² SORT : Dont ignore '#' #

FROM        TO
----------------
 aaa    #aaa  
#aaa    #bbb  
 bbb     aaa  
#bbb     bbb  
  1. Compare first char
  2. If equal → compare the rest

Syntax:

sort -k START[,END] [-k START[,END]]

Where:
. START + END = field chars
. Fields separated by whitespace (default)
. chars are 1-based

Method: 2 sort keys, applied one after another

sort -k 1.1,1.1 -k 1.2

Grouping: FROM field 1, char 1 TO field 1, char 1
Key 1: -k 1.1,1.1
Sorting inside groups : field 1, char 2
Key 2: -k 1.2

.

² TL;DR : ??? #

³ "watchdogs" #

inotify

sudo pacman -S inotify-tools
which inotifywait
inotifywait --version
```1

alternatives

**entr**

```bash
# install
sudo pacman -Qs entr
# eg
ls ~/blog-local/*.md | entr -r rsync -av --exclude='.~*' ~/blog-local/ ~/blog-remote/
# cons
# needs eg `ls` -- no auto detect

systemd.path

watch dirs -> trigger service

see https://eog.prose.sh/cmp.cmd..systemd.path..watch.dir.and.sync

³ delete lines #

whole lines beginning with <

1^<.*\n?
2# ^ = start of line
3# < = literal <
4# .* = rest of line
5# \n? = also remove the newline so you don’t leave blank lines

delete any empty line (even lines with spaces):

1^\s*\n
2# ^\s* matches zero or more whitespace chars from the start of the line
3# \n removes the actual newline

only truly empty lines (no spaces):

1^\n

³ find foo OR bar #

1find . \( -name "*.htm" -o -name "*.html" \)
2
3# alternative
4find . -regex '.*\.html?'

Escape parentheses to prevent shell from eating them.

³ mpv #

1
2_useragent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
3
4mpv --user-agent="$_useragent" <URL>
5
6# or
7cat << EOG >> ~/.config/mpv/mpv.conf
8user-agent="_useragent"
9EOG

³ YAML #

https://developers.machinemetrics.com/docs/adapter-scripts/yaml

array inline

1# 
2tags: [feature, announcement]

is same as

1tags:
2  - feature
3  - announcement

Indent w/ min. 2 spaces. But NO TABS allowed!!

1authors:                # = key
2  - name: Alice         # = object / map
3    role: writer        # belongs to this object
4    socials:
5      twitter: alice42
6
7  - name: Bob
8...
1authors =
2[
3  { name: "Alice", role: "writer", socials: {twitter:"alice42"} },
4  { name: "Bob", role: "editor", socials: {twitter:"bob_edit"} }
5]

Tips

indentation 2 spaces at each level.

last updated: