Raymond Page
2018-06-28 18:23:03 UTC
I can use some assistance with how to capture the CSI GetWinSizePixels
output in a shell variable?
The CSI GetWinSizePixels works (in iterm2 or nested tmux), but the output
doesn't seem to be to stdout, so I'm wondering if I need to read a tty/pts
to capture the output into a shell variable. Should I print these escapes
to the tty or pts directly, or to stdout of the shell?
iterm2
printf "\u1b[14t" > /dev/tty
tmux+iterm2
printf "\u1bPtmux;]\u1b\u1b[14t\u1b\\" > /dev/tty
I'm hoping I can do something like:
getpix() { read PIXEL_SIZE < /dev/tty & printf "\u1b[14t" > /dev/tty ; echo
"${PIXEL_SIZE}" ; }
Real world use, I'm trying to convert tput lines/cols to pixels for imgcat
rendering via gnuplot so the gnuplot png output will fill the terminal
window.
alias gnuplot="__gnuplot"
__gnuplot() {
SIZE=$(stty size 2>/dev/null)
SIZE=${SIZE:-$(tput lines) $(tput cols)}
COLS=${SIZE#* }
ROWS=${SIZE% *}
COLUMNS=${COLUMNS:-${COLS}}
LINES=${LINES:-${ROWS}}
case "${GNUTERM%% *}" in
dumb) X=${COLUMNS} ; Y=$((LINES-3));;
png|sixelgd) PIXEL_SIZE=`echo -ne "\e[14t" >/dev/tty` ;
PX=${PIXEL_SIZE#*;}; PX=${X%t}; PY=${PIXEL_SIZE%;*}
X=$((PX*COLUMNS/COLS))
Y=$((PX*LINES/ROWS))
;;
esac
sed -i "s/^set term[[:space:]][^[:space:]]*/set term ${GNUTERM%% *}/"
~/.gnuplot
case "${GNUTERM%% *}" in
png) GNUTERM="${GNUTERM} size $X,$Y" \gnuplot "$@" | imgcat;;
*) GNUTERM="${GNUTERM} size $X,$Y" \gnuplot "$@" ;;
esac
}
LINES=$((LINES/2)) gnuplot -e "plot sin(x)"
output in a shell variable?
The CSI GetWinSizePixels works (in iterm2 or nested tmux), but the output
doesn't seem to be to stdout, so I'm wondering if I need to read a tty/pts
to capture the output into a shell variable. Should I print these escapes
to the tty or pts directly, or to stdout of the shell?
iterm2
printf "\u1b[14t" > /dev/tty
tmux+iterm2
printf "\u1bPtmux;]\u1b\u1b[14t\u1b\\" > /dev/tty
I'm hoping I can do something like:
getpix() { read PIXEL_SIZE < /dev/tty & printf "\u1b[14t" > /dev/tty ; echo
"${PIXEL_SIZE}" ; }
Real world use, I'm trying to convert tput lines/cols to pixels for imgcat
rendering via gnuplot so the gnuplot png output will fill the terminal
window.
alias gnuplot="__gnuplot"
__gnuplot() {
SIZE=$(stty size 2>/dev/null)
SIZE=${SIZE:-$(tput lines) $(tput cols)}
COLS=${SIZE#* }
ROWS=${SIZE% *}
COLUMNS=${COLUMNS:-${COLS}}
LINES=${LINES:-${ROWS}}
case "${GNUTERM%% *}" in
dumb) X=${COLUMNS} ; Y=$((LINES-3));;
png|sixelgd) PIXEL_SIZE=`echo -ne "\e[14t" >/dev/tty` ;
PX=${PIXEL_SIZE#*;}; PX=${X%t}; PY=${PIXEL_SIZE%;*}
X=$((PX*COLUMNS/COLS))
Y=$((PX*LINES/ROWS))
;;
esac
sed -i "s/^set term[[:space:]][^[:space:]]*/set term ${GNUTERM%% *}/"
~/.gnuplot
case "${GNUTERM%% *}" in
png) GNUTERM="${GNUTERM} size $X,$Y" \gnuplot "$@" | imgcat;;
*) GNUTERM="${GNUTERM} size $X,$Y" \gnuplot "$@" ;;
esac
}
LINES=$((LINES/2)) gnuplot -e "plot sin(x)"
--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.