diff options
author | Urbain Vaes <urbain@vaes.uk> | 2016-04-23 00:01:56 +0100 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2016-04-23 02:54:56 +0100 |
commit | a59263b6672009c3dc8615ffb6c03342c8da3cac (patch) | |
tree | a70252001288b85ede6c35b0987cbfa452d2c460 /zsh/.zsh | |
parent | a55bcab62ee5d7198ee11a8e801895404d5d14cf (diff) |
Change mutt colors
Diffstat (limited to 'zsh/.zsh')
-rw-r--r-- | zsh/.zsh/functions | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/zsh/.zsh/functions b/zsh/.zsh/functions index aad8b01..86c1894 100644 --- a/zsh/.zsh/functions +++ b/zsh/.zsh/functions @@ -4,47 +4,47 @@ if [[ -z ${ZSH_COLORS} ]]; then ZSH_COLORS=${HOME}/.local/share/zsh/colors.zsh fi -colorschemes=$(echo ${HOME}/.Xresources/**/* | sed "s#${HOME}/.Xresources/##g" | sed 's#base16/base16-##g') +colorschemes=$(echo ${HOME}/.Xresources/**/*.xresources | sed "s#${HOME}/.Xresources/##g" | sed 's#base16/base16-##g' | \ + sed 's/[^ ]\+\.256\.[^ ]\+//g' | sed 's/.xresources//g' | sed 's/[ ]\+/ /g' ) function colo { # Xresource file - if [[ -z $1 ]]; then - XRESOURCE=$(echo ${colorschemes} | sed 's/ /\n/g' | fzf) - else + if [[ ! -z $1 ]]; then XRESOURCE=$1 + else + XRESOURCE=$(echo ${colorschemes} | sed 's/ /\n/g' | sed '/^[ ]*$/d' | fzf) + [[ -z ${XRESOURCE} ]] && return fi - if [[ -z ${XRESOURCE} ]]; then - return - fi - if [[ ! -f ${HOME}/.Xresources/${XRESOURCE} ]]; then - XRESOURCE=base16/base16-${XRESOURCE} - fi - if [[ ! -f ${HOME}/.Xresources/${XRESOURCE} ]]; then + if [[ -f ${HOME}/.Xresources/${XRESOURCE}.xresources ]]; then + XRESOURCE_FILE=${HOME}/.Xresources/${XRESOURCE}.xresources + elif [[ -f ${HOME}/.Xresources/base16/base16-${XRESOURCE}.256.xresources ]]; then + XRESOURCE_FILE=${HOME}/.Xresources/base16/base16-${XRESOURCE}.256.xresources + else echo "Invalid colorscheme!" return fi # Change colors for current session - /usr/bin/cpp ~/.Xresources/${XRESOURCE} | tr -d ' \t' | sed -n \ + /usr/bin/cpp ${XRESOURCE_FILE} | tr -d ' \t' | sed -n \ -e 's/.*background:/\x1b]11;/p' \ -e 's/.*foreground:/\x1b]10;/p' \ -e 's/.*color\([0-9][^:]*\):/\x1b]4;\1;/p' | tr \\n \\a # Ensure border color is the same as background - bg=$(/usr/bin/cpp ~/.Xresources/${XRESOURCE} | grep "background" | sed 's/[^ ]\+[ ]\+\([^ ]\+\)$/\1/') + bg=$(/usr/bin/cpp ${XRESOURCE_FILE} | grep "background" | sed 's/[^ ]\+[ ]\+\([^ ]\+\)$/\1/') echo "\x1b]708;${bg}" | tr \\n \\a # Load Xresources file for future sessions xrdb ~/.Xresources/base.xresources - xrdb -merge ~/.Xresources/${XRESOURCE} + xrdb -merge ${XRESOURCE_FILE} xrdb -merge <<< "URxvt.borderColor: ${bg}" # Change default environment variable for future sessions mkdir -p $(dirname ${ZSH_COLORS}) - COLORSCHEME=$(echo $(basename ${XRESOURCE}) | sed 's/\([^.]\+\)\..\+$/\1/g') - BACKGROUND=$(echo ${XRESOURCE} | sed 's/^.\+\(dark\|light\).\+$/\1/') + COLORSCHEME=$(echo $(basename ${XRESOURCE_FILE}) | sed 's/\([^.]\+\)\..\+$/\1/g') + BACKGROUND=$(echo ${XRESOURCE_FILE} | sed 's/^.\+\(dark\|light\).\+$/\1/') echo "export COLORSCHEME=${COLORSCHEME}" > ${ZSH_COLORS} echo "export BACKGROUND=${BACKGROUND}" >> ${ZSH_COLORS} |