Skip to content

Instantly share code, notes, and snippets.

@changemewtf
Created October 20, 2010 17:26
Show Gist options
  • Save changemewtf/636883 to your computer and use it in GitHub Desktop.
Save changemewtf/636883 to your computer and use it in GitHub Desktop.
Sets your $TERM to 256color if the termcap entry exists. Particularly useful for gnome-terminal, which has no option to set $TERM.
case "$TERM" in
*-256color)
alias ssh='TERM=${TERM%-256color} ssh'
;;
*)
POTENTIAL_TERM=$TERM-256color
POTENTIAL_TERMINFO=${TERM:0:1}/$POTENTIAL_TERM
BOX_TERMINFO_DIR=/usr/share/terminfo
[[ -f $BOX_TERMINFO_DIR/$POTENTIAL_TERMINFO ]] && export TERM=$POTENTIAL_TERM
HOME_TERMINFO_DIR=$HOME/.terminfo
[[ -f $HOME_TERMINFO_DIR/$POTENTIAL_TERMINFO ]] && export TERM=$POTENTIAL_TERM
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment