summaryrefslogtreecommitdiff
path: root/gemfeed
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-15 13:55:57 +0200
committerPaul Buetow <paul@buetow.org>2024-12-15 13:55:57 +0200
commitd38bb8203abaa5618cbcaf051bf2ccf1ceb0939d (patch)
tree09f1823b08ffafaa9c3915f0baad3ee04ca837eb /gemfeed
parentaaefbae71512fd72a6496f470fa3fe913383b740 (diff)
Update content for md
Diffstat (limited to 'gemfeed')
-rw-r--r--gemfeed/2024-12-15-random-helix-themes.md57
-rw-r--r--gemfeed/index.md1
2 files changed, 58 insertions, 0 deletions
diff --git a/gemfeed/2024-12-15-random-helix-themes.md b/gemfeed/2024-12-15-random-helix-themes.md
new file mode 100644
index 00000000..187e8d15
--- /dev/null
+++ b/gemfeed/2024-12-15-random-helix-themes.md
@@ -0,0 +1,57 @@
+# Random Helix themes
+
+> Published at 2024-12-15T13:55:05+02:00
+
+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.
+
+[https://helix-editor.com/](https://helix-editor.com/)
+
+So I put this into my `zsh` dotfiles (in some `editor.zsh.source` in my `~` directory):
+
+```sh
+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"
+ 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)"
+
+ 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
+```
+
+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.
+
+```sh
+[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] ~ %
+```
+
+I hope you had some fun. E-Mail your comments to `paul@nospam.buetow.org` :-)
+
+[Back to the main site](../)
diff --git a/gemfeed/index.md b/gemfeed/index.md
index eaab8e5e..253e7196 100644
--- a/gemfeed/index.md
+++ b/gemfeed/index.md
@@ -2,6 +2,7 @@
## To be in the .zone!
+[2024-12-15 - Random Helix themes](./2024-12-15-random-helix-themes.md)
[2024-12-03 - f3s: Kubernetes with FreeBSD - Part 2: Hardware and base installation](./2024-12-03-f3s-kubernetes-with-freebsd-part-2.md)
[2024-11-17 - f3s: Kubernetes with FreeBSD - Part 1: Setting the stage](./2024-11-17-f3s-kubernetes-with-freebsd-part-1.md)
[2024-10-24 - 'Staff Engineer' book notes](./2024-10-24-staff-engineer-book-notes.md)