#!/bin/zsh [[ -z ${ZSH_COLORS} ]] && ZSH_COLORS=${HOME}/.local/share/zsh/colors.zsh [[ -f ${ZSH_COLORS} ]] && source ${ZSH_COLORS} colorschemes=$(ls ${HOME}/.Xresources) function colo { XRESOURCE=$1 XRESOURCE_FILE=${HOME}/.Xresources/${XRESOURCE} # Change colors for current session /usr/bin/cpp ${XRESOURCE_FILE} | tr -d ' \t' | sed -n \ -e 's/.*background:/\x1b]11;/p' \ -e 's/.*foreground:/\x1b]10;/p' \ -e 's/.*borderColor:/\x1b]708;/p' \ -e 's/.*color\([0-9][^:]*\):/\x1b]4;\1;/p' | tr \\n "\007" [ ! -z "$TMUX" ] && printf '\033Ptmux;\033\033]11;white\007\033' # Change color for future sessions xrdb ${XRESOURCE_FILE} # Change default environment variable for future sessions mkdir -p $(dirname ${ZSH_COLORS}) echo "export COLORSCHEME=${XRESOURCE%.*}" > ${ZSH_COLORS} echo "export BACKGROUND=${XRESOURCE#*.}" >> ${ZSH_COLORS} echo "export XRESOURCE=${XRESOURCE}" >> ${ZSH_COLORS} source ${ZSH_COLORS} } # Completion for colorschemes (-M -> Case insensitive) compctl -k "(${colorschemes})" -M 'm:{a-z}={A-Z}' colo