From caecfe66ecd26b49ddab2c2e025e1f457cd56122 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 18 Dec 2024 23:28:24 +0200 Subject: Update content for html --- gemfeed/2024-12-15-random-helix-themes.html | 39 ++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'gemfeed/2024-12-15-random-helix-themes.html') diff --git a/gemfeed/2024-12-15-random-helix-themes.html b/gemfeed/2024-12-15-random-helix-themes.html index 817ca5e9..21d15604 100644 --- a/gemfeed/2024-12-15-random-helix-themes.html +++ b/gemfeed/2024-12-15-random-helix-themes.html @@ -10,7 +10,7 @@

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.

@@ -69,6 +69,43 @@ http://www.gnu.org/software/src-highlite --> [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:
+
+ +
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
-- cgit v1.2.3