From 66a666e4b4c852725880234a579c8b1ce726a944 Mon Sep 17 00:00:00 2001 From: David Thurstenson Date: Thu, 9 Feb 2017 18:25:32 -0600 Subject: [PATCH] Add function that wrapps any command to temporarily change terminfo --- .bashrc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index 59b1334..d2ee157 100644 --- a/.bashrc +++ b/.bashrc @@ -92,11 +92,23 @@ alias lsblk='lsblk -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT' alias nmap='sudo -E nmap' # I'm tired of managing weechat configs and multiple nicks -# Client depends: ssh, mosh, correct ssh host configuration -# Server depends: ssh, mosh, tmux, weechat, weechat.service (custom) +# Reference: https://wiki.thurstylark.com/Weechat.html # If you don't have weechat installed, connect to the existing tmux session through mosh [[ ! -s /usr/bin/weechat ]] && alias weechat='mosh vps -- tmux attach -dt weechat' # If you are thurstylark-vps, connect to the existing tmux session locally [[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat' +chterm() { # Command wrapper to temporarily switch to screen-256color terminfo and back. + # This is unfortunately necessary because Debian has literally no package + # that provides tmux-256color terminfo, and I have to ssh into debian boxes + # all damn day. + local oldterm=$TERM + export TERM=screen-256color + tput init + printf "Terminfo is now '%s'\n" "$TERM" + $@ + export TERM=$oldterm + tput init + printf "Terminfo is now '%s'\n" "$TERM" +}