From 0100d1c64f75ff71665b0702f476bf941b3946bf Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Mon, 19 Feb 2024 15:14:55 +0000 Subject: [PATCH] feat(theme): Add theme support Add support for both pywal and theme.sh terminal themes --- theme | 32 ++++++++++++++++++++++++++++++++ zshrc | 1 + 2 files changed, 33 insertions(+) create mode 100644 theme diff --git a/theme b/theme new file mode 100644 index 0000000..dd082f5 --- /dev/null +++ b/theme @@ -0,0 +1,32 @@ +# Attempt to load pywal theme first (unless disabled) +if has 'wal' ; then + if [[ -z $NO_PYWAL ]]; then + if [[ -e $XDG_CACHE_HOME/wal/sequences ]]; then + cat $XDG_CACHE_HOME/wal/sequences && return + fi + wal -qnR && return + fi +fi + +# Load theme.sh theme uses theme_history to set +if has 'theme.sh'; then + # Load the last set theme automatically + [ -e ~/.config/.theme_history ] && theme.sh "$(theme.sh -l|tail -n1)" + + + # Toggle between last set themes + + last_theme() { + theme.sh "$(theme.sh -l | tail -n2 | head -n1)" + } + + zle -N last_theme + bindkey '^o' last_theme + + alias th='theme.sh -i' + + alias thl='theme.sh --light -i' + alias thd='theme.sh --dark -i' +fi + +# vim: ft=zsh diff --git a/zshrc b/zshrc index 1ced751..1ee6507 100644 --- a/zshrc +++ b/zshrc @@ -37,6 +37,7 @@ source ${ZDOTDIR}/prompt source ${ZDOTDIR}/keyboard source ${ZDOTDIR}/history source ${ZDOTDIR}/hooks +source ${ZDOTDIR}/theme ## Set options