summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrbain Vaes <urbain@vaes.uk>2017-05-09 12:06:42 +0100
committerUrbain Vaes <urbain@vaes.uk>2017-05-09 12:06:42 +0100
commitbf681b02022b8bee8c122d0d3de2f1d4a3d0a174 (patch)
tree86a317ba735b19e76f869f2d48a5493896b2076d
parent6bd95ac1fbad3b9294d197cc248f8b68349f20c4 (diff)
Make colo function work in tmux
-rw-r--r--zsh/.zsh/functions16
1 files changed, 11 insertions, 5 deletions
diff --git a/zsh/.zsh/functions b/zsh/.zsh/functions
index ae85104..0735fa2 100644
--- a/zsh/.zsh/functions
+++ b/zsh/.zsh/functions
@@ -11,13 +11,19 @@ function colo {
XRESOURCE_FILE=${HOME}/.Xresources/${XRESOURCE}
# Change colors for current session
+ if [[ ! -z "$TMUX" ]]; then
+ printf '\x1bPtmux;'
+ esc='\x1b\x1b'
+ else
+ esc='\x1b'
+ fi
+
/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"
+ -e "s/.*background:/${esc}]11;/p" \
+ -e "s/.*foreground:/${esc}]10;/p" \
+ -e "s/.*borderColor:/${esc}]708;/p" \
+ -e "s/.*color\\([0-9][^:]*\\):/${esc}]4;\\1;/p" | tr \\n \\a
- [ ! -z "$TMUX" ] && printf '\033Ptmux;\033\033]11;white\007\033'
# Change color for future sessions
xrdb ${XRESOURCE_FILE}