summaryrefslogtreecommitdiff
path: root/gemfeed
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-18 23:28:25 +0200
committerPaul Buetow <paul@buetow.org>2024-12-18 23:28:25 +0200
commit686897868bd614986de25a9fb8e08b062a6cc6eb (patch)
tree6b307b627a8ca096c0ca2374b9efcaf1de3712c5 /gemfeed
parent2a199f6434c7aa4aa790723108952746ea2a7fa4 (diff)
Update content for md
Diffstat (limited to 'gemfeed')
-rw-r--r--gemfeed/2024-12-15-random-helix-themes.md36
1 files changed, 35 insertions, 1 deletions
diff --git a/gemfeed/2024-12-15-random-helix-themes.md b/gemfeed/2024-12-15-random-helix-themes.md
index c3af9589..1f5ef449 100644
--- a/gemfeed/2024-12-15-random-helix-themes.md
+++ b/gemfeed/2024-12-15-random-helix-themes.md
@@ -1,6 +1,6 @@
# Random Helix Themes
-> Published at 2024-12-15T13:55:05+02:00
+> Published at 2024-12-15T13:55:05+02:00; Last updated 2024-12-18
I thought it would be fun to have a random Helix theme every time I open a new shell. Helix is the text editor I use.
@@ -53,6 +53,40 @@ theme = "noctis"
[paul@earth] ~ %
```
+## A better version
+
+> Update 2024-12-18: This is an improved version, which works cross platform (e.g., also on MacOS) and multiple theme directories:
+
+```sh
+export EDITOR=hx
+export VISUAL=$EDITOR
+export GIT_EDITOR=$EDITOR
+export HELIX_CONFIG_DIR=$HOME/.config/helix
+
+editor::helix::theme::get_random () {
+ for dir in $(hx --health \
+ | awk '/^Runtime directories/ { print $3 }' | tr ';' ' '); do
+ if [ -d $dir/themes ]; then
+ ls $dir/themes
+ fi
+ done | grep -F .toml | sort -R | head -n 1 | cut -d. -f1
+}
+
+editor::helix::theme::set () {
+ local -r theme="$1"; shift
+
+ local -r config_file=$HELIX_CONFIG_DIR/config.toml
+
+ sed "/^theme =/ { s/.*/theme = \"$theme\"/; }" \
+ $config_file > $config_file.tmp &&
+ mv $config_file.tmp $config_file
+}
+
+if [ -f $HELIX_CONFIG_DIR/config.toml ]; then
+ editor::helix::theme::set $(editor::helix::theme::get_random)
+fi
+```
+
I hope you had some fun. E-Mail your comments to `paul@nospam.buetow.org` :-)
[Back to the main site](../)