summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrbain Vaes <urbain@vaes.uk>2016-06-03 11:34:07 +0100
committerUrbain Vaes <urbain@vaes.uk>2016-06-03 11:34:07 +0100
commitef803f14c11fd15d55fb6dfd2a146f5a11171eb1 (patch)
treea1128d95b929316bb5be295aa6444e79b9b395ae
parent058d7d81ca772d5efd826d2ae74d3dc15a6ec18f (diff)
Clean function for colorschemes
-rw-r--r--Xresources/.Xresources/base (renamed from Xresources/.Xresources/base.xresources)0
-rw-r--r--Xresources/.Xresources/seoul256.dark (renamed from Xresources/.Xresources/seoul256.dark.xresources)3
-rw-r--r--Xresources/.Xresources/solarized.dark (renamed from Xresources/.Xresources/solarized.mine.dark.xresources)2
-rw-r--r--Xresources/.Xresources/solarized.light (renamed from Xresources/.Xresources/solarized.mine.light.xresources)2
-rw-r--r--Xresources/.Xresources/transparent (renamed from Xresources/.Xresources/transparent.xresources)2
-rw-r--r--zsh/.zsh/functions43
6 files changed, 18 insertions, 34 deletions
diff --git a/Xresources/.Xresources/base.xresources b/Xresources/.Xresources/base
index 724c04c..724c04c 100644
--- a/Xresources/.Xresources/base.xresources
+++ b/Xresources/.Xresources/base
diff --git a/Xresources/.Xresources/seoul256.dark.xresources b/Xresources/.Xresources/seoul256.dark
index ad67aa5..f775e12 100644
--- a/Xresources/.Xresources/seoul256.dark.xresources
+++ b/Xresources/.Xresources/seoul256.dark
@@ -1,4 +1,5 @@
-! Border color
+#include "/home/urbain/.Xresources/base"
+
URxvt.borderColor: #3a3a3a
! Background / Foreground
diff --git a/Xresources/.Xresources/solarized.mine.dark.xresources b/Xresources/.Xresources/solarized.dark
index c820c23..9fdfd89 100644
--- a/Xresources/.Xresources/solarized.mine.dark.xresources
+++ b/Xresources/.Xresources/solarized.dark
@@ -1,3 +1,5 @@
+#include "/home/urbain/.Xresources/base"
+
URxvt.borderColor: #002b36
*background: #002b36
diff --git a/Xresources/.Xresources/solarized.mine.light.xresources b/Xresources/.Xresources/solarized.light
index 5d076f4..d19cf66 100644
--- a/Xresources/.Xresources/solarized.mine.light.xresources
+++ b/Xresources/.Xresources/solarized.light
@@ -1,3 +1,5 @@
+#include "/home/urbain/.Xresources/base"
+
URxvt.borderColor: #fdf6e3
*background: #fdf6e3
diff --git a/Xresources/.Xresources/transparent.xresources b/Xresources/.Xresources/transparent
index 39d696c..5f72f38 100644
--- a/Xresources/.Xresources/transparent.xresources
+++ b/Xresources/.Xresources/transparent
@@ -1,3 +1,5 @@
+#include "/home/urbain/.Xresources/base"
+
! True transparency
URxvt.transparent: true
URxvt.shading: 10
diff --git a/zsh/.zsh/functions b/zsh/.zsh/functions
index 5d629c7..5ea454f 100644
--- a/zsh/.zsh/functions
+++ b/zsh/.zsh/functions
@@ -1,47 +1,30 @@
#!/bin/zsh
-if [[ -z ${ZSH_COLORS} ]]; then
- ZSH_COLORS=${HOME}/.local/share/zsh/colors.zsh
-fi
+[[ -z ${ZSH_COLORS} ]] && ZSH_COLORS=${HOME}/.local/share/zsh/colors.zsh
+[[ -f ${ZSH_COLORS} ]] && source ${ZSH_COLORS}
-if [[ -d ${HOME}/.Xresources ]]; then
- 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' )
-fi
+colorschemes=$(echo ${HOME}/.Xresources/* | sed "s#${HOME}/.Xresources/##g")
function colo {
- # Xresource file
- if [[ ! -z $1 ]]; then
- XRESOURCE=$1
- else
- XRESOURCE=$(echo ${colorschemes} | sed 's/ /\n/g' | sed '/^[ ]*$/d' | fzf)
- [[ -z ${XRESOURCE} ]] && return
- fi
- 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
+ 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 \\a
- # Ensure border color is the same as background
- bg=$(/usr/bin/cpp ${XRESOURCE_FILE} | grep "background" | sed 's/[^ ]\+[ ]\+\([^ ]\+\)$/\1/')
- echo "\x1b]708;${bg}" | tr \\n \\a
+ # Change color for future sessions
+ xrdb ${XRESOURCE_FILE}
# Change default environment variable for future sessions
mkdir -p $(dirname ${ZSH_COLORS})
- COLORSCHEME=$(echo $(basename ${XRESOURCE_FILE}) | sed 's/\([^.]\+\)\..\+$/\1/g')
- BACKGROUND=$(echo ${XRESOURCE_FILE} | sed 's/^.\+\(dark\|light\).\+$/\1/')
+ COLORSCHEME=$(echo ${XRESOURCE} | sed 's/\([^.]\+\)\..\+$/\1/g')
+ BACKGROUND=$(echo ${XRESOURCE} | sed 's/^.\+\(dark\|light\)/\1/')
echo "export COLORSCHEME=${COLORSCHEME}" > ${ZSH_COLORS}
echo "export BACKGROUND=${BACKGROUND}" >> ${ZSH_COLORS}
@@ -49,11 +32,5 @@ function colo {
source ${ZSH_COLORS}
}
-# Source colors
-if [[ -f ${ZSH_COLORS} ]]; then
- source ${ZSH_COLORS}
- colo ${XRESOURCE}
-fi
-
# Completion for colorschemes (-M -> Case insensitive)
compctl -k "(${colorschemes})" -M 'm:{a-z}={A-Z}' colo