From ee75979b5d94ae18f930ff91e5b2d51cd554b60d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 9 Mar 2026 22:45:54 +0200 Subject: Update content for html --- gemfeed/2024-12-15-random-helix-themes.html | 125 +++++++++++++--------------- 1 file changed, 60 insertions(+), 65 deletions(-) (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 351086a9..3b399487 100644 --- a/gemfeed/2024-12-15-random-helix-themes.html +++ b/gemfeed/2024-12-15-random-helix-themes.html @@ -2,17 +2,12 @@ - Random Helix Themes -
-
-
-

Home | Markdown | Gemini

@@ -30,33 +25,33 @@ by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
export EDITOR=hx
-export VISUAL=$EDITOR
-export GIT_EDITOR=$EDITOR
-export HELIX_CONFIG_DIR=$HOME/.config/helix
+
export EDITOR=hx
+export VISUAL=$EDITOR
+export GIT_EDITOR=$EDITOR
+export HELIX_CONFIG_DIR=$HOME/.config/helix
 
-editor::helix::random_theme () {
-    # May add more theme search paths based on OS. This one is
-    # for Fedora Linux, but there is also MacOS, etc.
-    local -r theme_dir=/usr/share/helix/runtime/themes
-    if [ ! -d $theme_dir ]; then
-        echo "Helix theme dir $theme_dir doesnt exist"
-        return 1
-    fi
+editor::helix::random_theme () {
+    # May add more theme search paths based on OS. This one is
+    # for Fedora Linux, but there is also MacOS, etc.
+    local -r theme_dir=/usr/share/helix/runtime/themes
+    if [ ! -d $theme_dir ]; then
+        echo "Helix theme dir $theme_dir doesnt exist"
+        return 1
+    fi
 
-    local -r config_file=$HELIX_CONFIG_DIR/config.toml
-    local -r random_theme="$(basename "$(ls $theme_dir \
-        | grep -v random.toml | grep .toml | sort -R \
-        | head -n 1)" | cut -d. -f1)"
+    local -r config_file=$HELIX_CONFIG_DIR/config.toml
+    local -r random_theme="$(basename "$(ls $theme_dir \
+        | grep -v random.toml | grep .toml | sort -R \
+        | head -n 1)" | cut -d. -f1)"
 
-    sed "/^theme =/ { s/.*/theme = \"$random_theme\"/; }" \
-        $config_file > $config_file.tmp && 
-        mv $config_file.tmp $config_file
-}
+    sed "/^theme =/ { s/.*/theme = \"$random_theme\"/; }" \
+        $config_file > $config_file.tmp && 
+        mv $config_file.tmp $config_file
+}
 
-if [ -f $HELIX_CONFIG_DIR/config.toml ]; then
-    editor::helix::random_theme
-fi
+if [ -f $HELIX_CONFIG_DIR/config.toml ]; then
+    editor::helix::random_theme
+fi
 

So every time I open a new terminal or shell, editor::helix::random_theme gets called, which randomly selects a theme from all installed ones and updates the helix config accordingly.
@@ -65,16 +60,16 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
[paul@earth] ~ % editor::helix::random_theme
-[paul@earth] ~ % head -n 1 ~/.config/helix/config.toml
-theme = "jellybeans"
-[paul@earth] ~ % editor::helix::random_theme
-[paul@earth] ~ % head -n 1 ~/.config/helix/config.toml
-theme = "rose_pine"
-[paul@earth] ~ % editor::helix::random_theme
-[paul@earth] ~ % head -n 1 ~/.config/helix/config.toml
-theme = "noctis"
-[paul@earth] ~ %
+
[paul@earth] ~ % editor::helix::random_theme
+[paul@earth] ~ % head -n 1 ~/.config/helix/config.toml
+theme = "jellybeans"
+[paul@earth] ~ % editor::helix::random_theme
+[paul@earth] ~ % head -n 1 ~/.config/helix/config.toml
+theme = "rose_pine"
+[paul@earth] ~ % editor::helix::random_theme
+[paul@earth] ~ % head -n 1 ~/.config/helix/config.toml
+theme = "noctis"
+[paul@earth] ~ %
 

A better version


@@ -85,44 +80,44 @@ http://www.gnu.org/software/src-highlite --> by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -
export EDITOR=hx
-export VISUAL=$EDITOR
-export GIT_EDITOR=$EDITOR
-export HELIX_CONFIG_DIR=$HOME/.config/helix
+
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::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
+editor::helix::theme::set () {
+    local -r theme="$1"; shift
 
-    local -r config_file=$HELIX_CONFIG_DIR/config.toml
+    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
-}
+    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
+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