diff --git a/README.md b/README.md index 7a2be03..eb0d2ce 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ Who is who in **bin** directory: - `b` create an indented C-like block `{ ... }` - `c SYMBOL`/`uc SYMBOL` comment/uncomment selection - `commit MESSAGE` commit and push to master +- `css` and `cssify` transform abbreviations into CSS properties - `f TEXT` find TEXT using The Silver Searcher - `hd SYMBOL` draw a pretty heading - `htm` feed selection to [Pug](https://github.com/pugjs/pug) diff --git a/bin/css b/bin/css new file mode 100755 index 0000000..13c93e9 --- /dev/null +++ b/bin/css @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +echo addr=dot | 9p write acme/$winid/ctl +echo -n '__MARKER__' | 9p write acme/$winid/data +echo -n '/^.*__MARKER__/' | 9p write acme/$winid/addr +echo dot=addr | 9p write acme/$winid/ctl +in=$(9p read acme/$winid/xdata | sed 's/__MARKER__//') +out=$(echo "$in" | cssify) +echo addr=dot | 9p write acme/$winid/ctl +echo -n "$out" | 9p write acme/$winid/data diff --git a/bin/cssify b/bin/cssify new file mode 100755 index 0000000..2a28efd --- /dev/null +++ b/bin/cssify @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +awk ' +BEGIN { + css["f"]="font" + css["fz"]="font-size" + css["w"]="width" + css["h"]="height" +} + +function cssify(line) { + i = match(line, "[a-z]") + tabs = "" + if (i > 1) { + n_tabs = i - 1 + tabs = "" + while (n_tabs-- > 0) { + tabs = tabs" " + } + } + gsub("[ ]", "", line) + if (line in css) { + return tabs css[line] ": ;" + } + return tabs "?" +} + +{ + print cssify($0) +} +'