dotwryn/zsh/colors

77 lines
2.5 KiB
Plaintext
Raw Normal View History

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
2019-12-31 02:45:05 +00:00
alias ls='ls --color=auto';
2021-09-16 20:56:05 +00:00
#####################################################################
2019-12-31 00:48:53 +00:00
2021-09-16 20:56:05 +00:00
GENERATE_PS1() {
local INDICATOR_SYMBOL="$1"
local PROMPT_USER="$2"
local SEPARATOR="$3"
2019-12-31 02:00:58 +00:00
2021-09-16 20:56:05 +00:00
local _INDICATOR="%B%(?.%F{green}.%F{red}) $INDICATOR_SYMBOL"
local _USER="%B%F{magenta}$PROMPT_USER"
local _SEPARATOR="%b%F{red}$SEPARATOR"
local _DIRECTORY='%B%F{yellow}%6~'
local _GIT_BRANCH='%B%F{cyan}$(git branch --no-color 2>/dev/null | sed "/^[^*]/d; s/* \(.*\)/  \1/")'
2019-12-31 02:00:58 +00:00
2021-09-16 20:56:05 +00:00
local _PROMPT=$'\n'' %B%F{blue}%# %b%f'
2019-12-31 02:00:58 +00:00
2021-09-16 20:56:05 +00:00
echo "$_INDICATOR $_USER $_SEPARATOR $_DIRECTORY $_GIT_BRANCH $_PROMPT"
2019-12-31 02:45:05 +00:00
}
2019-12-31 02:00:58 +00:00
setopt PROMPT_SUBST
2021-09-16 20:56:05 +00:00
export PS1="$(GENERATE_PS1 "$PS1_INDICATOR_SYMBOL" "$PS1_USER" "$PS1_SEPARATOR")"
2021-06-28 19:09:54 +00:00
2021-09-16 20:56:05 +00:00
#####################################################################
source "$DOTWRYN/config/colorschemes/linux-console"
2021-06-28 19:09:54 +00:00
alias tty-change-theme='TTY_CHANGE_THEME'
function TTY_CHANGE_THEME() {
local TARGET_THEME_LINK="$HOME/.config/wryn/tty-colorscheme"
local SOURCE_THEME="$DOTWRYN/config/colorschemes/kitty/$1"
2021-06-28 19:09:54 +00:00
[ ! $1 ] && { echo must specify colorscheme; return 1; }
[[ $1 =~ ^current-kitty-theme$ ]] && {
rm $TARGET_THEME_LINK >/dev/null 2>&1
} || {
[ ! -f $SOURCE_THEME ] && { echo no such colorscheme; return 2; }
rm $TARGET_THEME_LINK >/dev/null 2>&1
ln -s $SOURCE_THEME $TARGET_THEME_LINK
}
echo 'TTY colorscheme updated; resource shell in TTY for changes to take effect'
source "$DOTWRYN/config/colorschemes/linux-console"
2021-06-28 19:09:54 +00:00
}
_TTY_CHANGE_THEME() {
compadd $(ls $DOTWRYN/config/colorschemes/kitty) current-kitty-theme
2021-06-28 19:09:54 +00:00
}
compdef _TTY_CHANGE_THEME TTY_CHANGE_THEME;
2021-09-16 20:56:05 +00:00
#####################################################################
2021-06-28 19:09:54 +00:00
alias kitty-change-theme='KITTY_CHANGE_THEME default'
alias kitty-change-theme-alternate='KITTY_CHANGE_THEME alternate'
function KITTY_CHANGE_THEME () {
[ ! $2 ] && echo no filename given :c && return 1;
[ ! -f "$DOTWRYN/config/colorschemes/kitty/$2" ] \
&& echo colorscheme not supported && return 2;
local THEME_DIR="$DOTWRYN/config/kitty";
local THEME;
[ $1 = 'default' ] && THEME="$THEME_DIR/theme.conf" || THEME="$THEME_DIR/alternate.conf"
rm "$THEME"
ln -s "$DOTWRYN/config/colorschemes/kitty/$2" "$THEME"\
&& echo 'theme changed successfully! (effective on new terminal session)'
2021-06-28 19:09:54 +00:00
[ -f "$HOME/.config/wryn/tty-colorscheme" ] && source "$HOME/.config/wryn/tty-colorscheme"
}
_KITTY_CHANGE_THEME () {
compadd $(ls $DOTWRYN/config/colorschemes/kitty)
}
compdef _KITTY_CHANGE_THEME KITTY_CHANGE_THEME;