diff --git a/.config/shell/colors.sh b/.config/shell/colors.sh new file mode 100644 index 0000000..23c14c6 --- /dev/null +++ b/.config/shell/colors.sh @@ -0,0 +1,126 @@ +#!/bin/sh +# base16-shell (https://github.com/chriskempson/base16-shell) +# Base16 Shell template by Chris Kempson (http://chriskempson.com) +# OneDark scheme by Lalit Magant (http://github.com/tilal6991) + +color00="1b/1d/1e" # Base 00 - Black +color01="ff/59/95" # Base 08 - Red +color02="b6/e3/54" # Base 0B - Green +color03="f3/fd/21" # Base 0A - Yellow +color04="3f/78/ff" # Base 0D - Blue +color05="9e/6f/fe" # Base 0E - Magenta +color06="23/ce/d4" # Base 0C - Cyan +color07="cc/cc/c6" # Base 05 - White +color08="50/53/54" # Base 03 - Bright Black +color09=$color01 # Base 08 - Bright Red +color10=$color02 # Base 0B - Bright Green +color11=$color03 # Base 0A - Bright Yellow +color12=$color04 # Base 0D - Bright Blue +color13=$color05 # Base 0E - Bright Magenta +color14=$color06 # Base 0C - Bright Cyan +color15="f8/f8/f2" # Base 07 - Bright White +color16="d1/9a/66" # Base 09 +color17="be/50/46" # Base 0F +color18="35/3b/45" # Base 01 +color19="3e/44/51" # Base 02 +color20="56/5c/64" # Base 04 +color21="b6/bd/ca" # Base 06 +color_foreground="ab/b2/bf" # Base 05 +color_background="28/2c/34" # Base 00 + +if [ -n "$TMUX" ]; then + # Tell tmux to pass the escape sequences through + # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) + put_template() { printf '\033Ptmux;\033\033]4;%d;rgb:%s\033\033\\\033\\' $@; } + put_template_var() { printf '\033Ptmux;\033\033]%d;rgb:%s\033\033\\\033\\' $@; } + put_template_custom() { printf '\033Ptmux;\033\033]%s%s\033\033\\\033\\' $@; } +elif [ "${TERM%%[-.]*}" = "screen" ]; then + # GNU screen (screen, screen-256color, screen-256color-bce) + put_template() { printf '\033P\033]4;%d;rgb:%s\007\033\\' $@; } + put_template_var() { printf '\033P\033]%d;rgb:%s\007\033\\' $@; } + put_template_custom() { printf '\033P\033]%s%s\007\033\\' $@; } +elif [ "${TERM%%-*}" = "linux" ]; then + put_template() { [ $1 -lt 16 ] && printf "\e]P%x%s" $1 $(echo $2 | sed 's/\///g'); } + put_template_var() { true; } + put_template_custom() { true; } +else + put_template() { printf '\033]4;%d;rgb:%s\033\\' $@; } + put_template_var() { printf '\033]%d;rgb:%s\033\\' $@; } + put_template_custom() { printf '\033]%s%s\033\\' $@; } +fi + +# 16 color space +put_template 0 $color00 +put_template 1 $color01 +put_template 2 $color02 +put_template 3 $color03 +put_template 4 $color04 +put_template 5 $color05 +put_template 6 $color06 +put_template 7 $color07 +put_template 8 $color08 +put_template 9 $color09 +put_template 10 $color10 +put_template 11 $color11 +put_template 12 $color12 +put_template 13 $color13 +put_template 14 $color14 +put_template 15 $color15 + +# 256 color space +put_template 16 $color16 +put_template 17 $color17 +put_template 18 $color18 +put_template 19 $color19 +put_template 20 $color20 +put_template 21 $color21 + +# foreground / background / cursor color +if [ -n "$ITERM_SESSION_ID" ]; then + # iTerm2 proprietary escape codes + put_template_custom Pg abb2bf # foreground + put_template_custom Ph 282c34 # background + put_template_custom Pi abb2bf # bold color + put_template_custom Pj 3e4451 # selection color + put_template_custom Pk abb2bf # selected text color + put_template_custom Pl abb2bf # cursor + put_template_custom Pm 282c34 # cursor text +else + put_template_var 10 $color_foreground + if [ "$BASE16_SHELL_SET_BACKGROUND" != false ]; then + put_template_var 11 $color_background + if [ "${TERM%%-*}" = "rxvt" ]; then + put_template_var 708 $color_background # internal border (rxvt) + fi + fi + put_template_custom 12 ";7" # cursor (reverse video) +fi + +# clean up +unset -f put_template +unset -f put_template_var +unset -f put_template_custom +unset color00 +unset color01 +unset color02 +unset color03 +unset color04 +unset color05 +unset color06 +unset color07 +unset color08 +unset color09 +unset color10 +unset color11 +unset color12 +unset color13 +unset color14 +unset color15 +unset color16 +unset color17 +unset color18 +unset color19 +unset color20 +unset color21 +unset color_foreground +unset color_background diff --git a/.zshrc b/.zshrc index 5a5577a..db2bc02 100644 --- a/.zshrc +++ b/.zshrc @@ -24,6 +24,8 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" export ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/zsh" + export ZINIT_HOME_DIR="" + # Plugin setting >>> { # ZSH Vi Mode @@ -193,6 +195,8 @@ # prcolors(): Display all colors in a few different ways >>> # TODO: change this to make it not just a few scripts smashed together prcolors() { + [ -z "$1" ] && 1=0 + if [ $1 -eq '1' ];then # Taken from manjaro's bashrc >>> local fgc bgc vals seq0 @@ -219,16 +223,17 @@ echo; echo done # <<< + elif [ $1 -eq '2' ];then # from base16shell >>> ansi_mappings=( - Black Red - Green Yellow - Blue Magenta - Cyan White - Bright_Black Bright_Red - Bright_Green Bright_Yellow - Bright_Blue Bright_Magenta - Bright_Cyan Bright_White + Red Green + Yellow Blue + Magenta Cyan + White Black + Bright_Red Bright_Green + Bright_Yellow Bright_Blue + Bright_Magenta Bright_Cyan + Bright_White Bright_Black ) colors=( base00 base08 @@ -255,19 +260,28 @@ foreground=$(printf "\x1b[38;5;${non_padded_value}m$color_variable") printf "%s %s %s %-30s %s\x1b[0m\n" $foreground $base16_color_name $current_color_label ${ansi_label:-""} $block done; - if [ $# -eq 1 ]; then - printf "To restore current theme, source ~/.base16_theme or reopen your terminal\n" - fi + #if [ $# -eq 1 ]; then + # printf "To restore current theme, source ~/.base16_theme or reopen your terminal\n" + #fi # <<< + elif [ $1 -eq '3' ];then # Similar to above, but does 256-bit colors. >>> # Taken from this: https://github.com/romkatv/powerlevel10k#set-colors-through-Powerlevel10k-configuration-parameters for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'} done # <<< + else + cat <<-EOF + Usage: prcolors + 1: Manjaro bashrc -- for checking text readability + 2: base26shell -- for seeing the 16 set terminal colors + 3: 256 -- for testing 256 color output + EOF + fi } # <<< - + # shellcheck disable=SC2016 mkcd() { mkdir -p "$1" || error $LINENO @@ -356,9 +370,13 @@ # Themes # zplug "themes/robbyrussell", from:oh-my-zsh, as:theme - zinit snippet 'https://github.com/chriskempson/base16-shell/blob/master/scripts/base16-onedark.sh' # onedark shell colors + if [[ -f ~/.config/shell/colors.sh ]];then + source ~/.config/shell/colors.sh + else + zinit snippet 'https://github.com/chriskempson/base16-shell/blob/master/scripts/base16-onedark.sh' # onedark shell colors + fi zinit load "romkatv/powerlevel10k" - [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + [[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh } # <<< }