From: Iain Patterson Date: Fri, 14 Sep 2012 14:58:41 +0000 (+0100) Subject: Script to set urxvt background colour on the fly. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=6c50c01c0cb5486964d139dd4f12b15464d984ec;p=profile.git Script to set urxvt background colour on the fly. --- diff --git a/opt/bin/ucolour b/opt/bin/ucolour new file mode 100755 index 0000000..796afda --- /dev/null +++ b/opt/bin/ucolour @@ -0,0 +1,51 @@ +#!/bin/bash +# +# ucolour: Set urxvt (or terminal which understands the same escape sequences) +# colours. +# Usage: ucolour option [option ...] +# Options: -b Set background. +# -B Set highlight background. +# -c Set cursor. +# -f Set foreground. +# -F Set highlight foreground. +# -m Set mouse. +# + +BG= +FG= +bg= +fg= +cu= +mo= +tmux_prefix= +while getopts ":B:F:b:c:f:m:" opt; do + case $opt in + B) BG=$OPTARG;; + F) FG=$OPTARG;; + b) bg=$OPTARG;; + c) cu=$OPTARG;; + f) fg=$OPTARG;; + m) mo=$OPTARG;; + esac +done +shift $((OPTIND-1)) + +if [ -z "$BG$FG$bg$cu$fg$mo" ]; then + echo >&2 "Usage: ucolour option [option ...]" + echo >&2 "Options: -b Set background." + echo >&2 " -B Set highlight background." + echo >&2 " -c Set cursor." + echo >&2 " -f Set foreground." + echo >&2 " -F Set highlight foreground." + echo >&2 " -m Set mouse." + exit 1 +fi + +[ -n "$TMUX" ] && tmux_prefix="\033Ptmux;\033" +[ -n "$BG" ] && echo -en "$tmux_prefix\033]17;$BG\007" +[ -n "$FG" ] && echo -en "$tmux_prefix\033]19;$FG\007" +[ -n "$bg" ] && echo -en "$tmux_prefix\033]11;$bg\007" +[ -n "$cu" ] && echo -en "$tmux_prefix\033]12;$cu\007" +[ -n "$fg" ] && echo -en "$tmux_prefix\033]10;$fg\007" +[ -n "$mo" ] && echo -en "$tmux_prefix\033]13;$mo\007" +exit 0