Add function that wrapps any command to temporarily change terminfo

This commit is contained in:
David Thurstenson 2017-02-09 18:25:32 -06:00
parent a8e4895b92
commit 66a666e4b4
1 changed files with 14 additions and 2 deletions

16
.bashrc
View File

@ -92,11 +92,23 @@ alias lsblk='lsblk -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT'
alias nmap='sudo -E nmap' alias nmap='sudo -E nmap'
# I'm tired of managing weechat configs and multiple nicks # I'm tired of managing weechat configs and multiple nicks
# Client depends: ssh, mosh, correct ssh host configuration # Reference: https://wiki.thurstylark.com/Weechat.html
# Server depends: ssh, mosh, tmux, weechat, weechat.service (custom)
# If you don't have weechat installed, connect to the existing tmux session through mosh # 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' [[ ! -s /usr/bin/weechat ]] && alias weechat='mosh vps -- tmux attach -dt weechat'
# If you are thurstylark-vps, connect to the existing tmux session locally # If you are thurstylark-vps, connect to the existing tmux session locally
[[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat' [[ "$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"
}