X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=opt%2Fbin%2Fusize;h=c287fa168f27db07960dd872aaa515727e2d9615;hp=7221e60155824ac24ac5998730b33f1a85bbb1e6;hb=08a2c3604c45a8760381f850986ad45e9aa6164f;hpb=819bb88d5a014a23150b8fd609d194e883958674 diff --git a/opt/bin/usize b/opt/bin/usize index 7221e60..c287fa1 100755 --- a/opt/bin/usize +++ b/opt/bin/usize @@ -3,10 +3,12 @@ # usize: Set urxvt (or terminal which understands the same escape sequences) # size. # Usage: usize [] +# Usage: usize x [x] # width=${COLUMNS:-80} height=${LINES:-24} +tmux_prefix= case $# in 0) @@ -17,5 +19,19 @@ case $# in 2) width=$1; height=$2;; esac -echo -e "\033[8;$height;$width;t" +# Allow, eg, x2 for width or height. +if [ ! "${width#x}" = "${width}" ]; then + # Add a column for dividers. + width=${width#x} + width=$((width-1+(87*width))) +fi +if [ ! "${height#x}" = "${height}" ]; then + height=${height#x} + height=$((24*height)) + # Add a row for tmux. + [ $height -gt 1 ] && height=$((height+2)) +fi + +[ -n "$TMUX" ] && tmux_prefix="\033Ptmux;\033" +echo -en "$tmux_prefix\033[8;$height;$width;t" exit 0