#!/bin/zsh ##################################################################### alias ls='ls --color=auto --group-directories-first' ##################################################################### _TTY_LOAD_COLORSCHEME() { [[ "$TERM" =~ ^linux$ ]] || return 0 local TARGET="$HOME/.config/wryn/tty-colorscheme" [ ! -f $TARGET ] && TARGET="$DOTWRYN/colorschemes/kitty.main" local PARSE() { grep "$1" $TARGET | awk '{print $2}' | sed 's/ //g; s/#//g' | tr '[:lower:]' '[:upper:]' } /bin/echo -e "\ \e]P0$(PARSE '^background ') \e]P1$(PARSE '^color1 ') \e]P2$(PARSE '^color2 ') \e]P3$(PARSE '^color3 ') \e]P4$(PARSE '^color4 ') \e]P5$(PARSE '^color5 ') \e]P6$(PARSE '^color6 ') \e]P7$(PARSE '^foreground ') \e]P8$(PARSE '^color9 ') \e]P9$(PARSE '^color10 ') \e]PA$(PARSE '^color11 ') \e]PB$(PARSE '^color12 ') \e]PC$(PARSE '^color13 ') \e]PD$(PARSE '^color14 ') \e]PE$(PARSE '^color7 ') \e]PF$(PARSE '^color15 ') " clear } _TTY_LOAD_COLORSCHEME ##################################################################### alias kitty-change-colorscheme='CHANGE_COLORSCHEME kitty main' alias kitty-change-colorscheme-alternate='CHANGE_COLORSCHEME kitty alternate' alias tty-change-theme='CHANGE_COLORSCHEME tty' CHANGE_COLORSCHEME () { local TYPE="$1" local TARGET_LINK EXTRA_OPTIONS case $TYPE in tty ) TARGET_LINK="$HOME/.config/wryn/tty-colorscheme" EXTRA_OPTIONS=(default) ;; kitty ) TARGET_LINK="$DOTWRYN/colorschemes/kitty.$2" EXTRA_OPTIONS=() ;; esac local COLORSCHEMES=($(cd $DOTWRYN/colorschemes; ls *.conf) $EXTRA_OPTIONS) local COLORSCHEME=$(\ echo $COLORSCHEMES | sed 's/\s\+/\n/g' | sort -u \ | sed 's/\.conf//g; s/^./\U&/; s/-\(.\)/\U\1/g; s/^Default/& (use kitty theme)/' \ | fzf -i --height=50% --reverse --prompt 'select a theme : ' \ | sed 's/^./\L&/; s/[A-Z]/-\L&/g' ) case $COLORSCHEME in '' ) return 1 ;; default* ) ;; * ) COLORSCHEME="$DOTWRYN/colorschemes/$COLORSCHEME.conf" [ ! -f $COLORSCHEME ] && { echo "no such theme">&2; return 2; } ;; esac rm -- $TARGET_LINK >/dev/null 2>&1 ln -s $COLORSCHEME $TARGET_LINK echo "'$TYPE' theme changed successfully! (effective on new session)" _TTY_LOAD_COLORSCHEME } #####################################################################