summaryrefslogtreecommitdiff
path: root/bin/zsh-colors.zsh
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
committerIgor Soarez <igor@soarez.org>2026-09-17 19:45:23 +0100
commit13cc065ec014b86369dfe4ad60d1a43fa06fd251 (patch)
tree684690c61b7b59758c2aac132c65b81c86de0608 /bin/zsh-colors.zsh
dotfiles
Shell, editor and terminal configuration, the tools that go with them, and szecret, an age-based secret manager whose store lives elsewhere. History restarts here. What came before was not written to be read by anyone else, and carried machine names, addresses and an encrypted secret store; it is kept privately instead. What is left is meant to be safe on any machine, including one whose owner is not me: see CLAUDE.md for the rule it is written to.
Diffstat (limited to 'bin/zsh-colors.zsh')
-rwxr-xr-xbin/zsh-colors.zsh39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/zsh-colors.zsh b/bin/zsh-colors.zsh
new file mode 100755
index 0000000..e1e9596
--- /dev/null
+++ b/bin/zsh-colors.zsh
@@ -0,0 +1,39 @@
+#! /bin/zsh
+# A script to make using 256 colors in zsh less painful.
+# P.C. Shyamshankar <sykora@lucentbeing.com>
+# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
+
+typeset -AHg FX FG BG
+
+FX=(
+ reset "%{%}"
+ bold "%{%}" no-bold "%{%}"
+ italic "%{%}" no-italic "%{%}"
+ underline "%{%}" no-underline "%{%}"
+ blink "%{%}" no-blink "%{%}"
+ reverse "%{%}" no-reverse "%{%}"
+)
+
+for color in {000..255}; do
+ FG[$color]="%{[38;5;${color}m%}"
+ BG[$color]="%{[48;5;${color}m%}"
+done
+
+
+ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
+
+# Show all 256 colors with color number
+function spectrum_ls() {
+ for code in {000..255}; do
+ print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
+ done
+}
+
+# Show all 256 colors where the background is set to specific color
+function spectrum_bls() {
+ for code in {000..255}; do
+ print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
+ done
+}
+
+spectrum_ls