2019-12-31 00:48:53 +00:00
|
|
|
#!/bin/zsh
|
2021-09-16 20:56:05 +00:00
|
|
|
#####################################################################
|
2019-12-31 00:48:53 +00:00
|
|
|
|
2021-09-17 04:42:41 +00:00
|
|
|
alias ls='ls --color=auto --group-directories-first'
|
2019-12-31 02:45:05 +00:00
|
|
|
|
2021-09-16 20:56:05 +00:00
|
|
|
#####################################################################
|
2019-12-31 00:48:53 +00:00
|
|
|
|
2022-02-06 07:15:14 +00:00
|
|
|
_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:]'
|
2021-09-21 17:00:31 +00:00
|
|
|
}
|
2022-02-06 07:15:14 +00:00
|
|
|
|
|
|
|
/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
|
2021-09-21 17:00:31 +00:00
|
|
|
}
|
2022-02-06 07:15:14 +00:00
|
|
|
_TTY_LOAD_COLORSCHEME
|
2021-06-28 19:09:54 +00:00
|
|
|
|
2021-09-29 17:34:15 +00:00
|
|
|
#####################################################################
|
2021-06-28 19:09:54 +00:00
|
|
|
|
2022-02-06 07:15:14 +00:00
|
|
|
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)/' \
|
2021-09-29 17:34:15 +00:00
|
|
|
| fzf -i --height=50% --reverse --prompt 'select a theme : ' \
|
|
|
|
| sed 's/^./\L&/; s/[A-Z]/-\L&/g'
|
2022-02-06 07:15:14 +00:00
|
|
|
)
|
2021-09-29 17:34:15 +00:00
|
|
|
|
2022-02-06 07:15:14 +00:00
|
|
|
case $COLORSCHEME in
|
|
|
|
'' ) return 1 ;;
|
|
|
|
default* ) ;;
|
2021-09-29 17:34:15 +00:00
|
|
|
* )
|
2022-02-06 07:15:14 +00:00
|
|
|
COLORSCHEME="$DOTWRYN/colorschemes/$COLORSCHEME.conf"
|
|
|
|
[ ! -f $COLORSCHEME ] && { echo "no such theme">&2; return 2; }
|
2021-09-29 17:34:15 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-02-06 07:15:14 +00:00
|
|
|
rm -- $TARGET_LINK >/dev/null 2>&1
|
|
|
|
ln -s $COLORSCHEME $TARGET_LINK
|
2021-09-21 17:00:31 +00:00
|
|
|
|
2022-02-06 07:15:14 +00:00
|
|
|
echo "'$TYPE' theme changed successfully! (effective on new session)"
|
|
|
|
_TTY_LOAD_COLORSCHEME
|
2021-06-28 19:09:54 +00:00
|
|
|
}
|
|
|
|
|
2021-09-16 20:56:05 +00:00
|
|
|
#####################################################################
|