From bc1b3826f18b5be1608f3f7ff9244fd95e705d0b Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Sat, 26 Jul 2014 04:45:44 -0400 Subject: [PATCH] Added a script to generate a terminfo file for tmux with support for italics, and added an explanation of how and why this works to the README. --- README.md | 4 ++++ tmux-italics-terminfo | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 tmux-italics-terminfo diff --git a/README.md b/README.md index 9748161..cad5e16 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ * (**copy mode**) `v`, `y` and `Escape`: Begin selection, copy selection and cancel **copy mode** respectively. * `Alt-[0-9]` (no prefix): Switch directly to the given window. +## Italics Support ## + +Tmux supports italics if your terminal does, but the terminfo files _screen_ and _screen-256color_ don't advertise this, and most programs will display reversed text when it should be italics. To fix this, run: `tmux-italics-terminfo`, then follow the instructions it displays by changing `set-option -g default-terminal "screen-256color"` to `set-option -g default-terminal "screen-256color-it"` in your _tmux.conf_. You'll want to make sure your _/etc/bash.bashrc_, _/etc/dircolors_, possibly **vim** and any other terminal applications that check the `$TERM` variable have _screen-it_ and _screen-256color-it_ added. + ## Credits ## * Written by Kevin MacMartin: [GitHub Projects](https://github.com/prurigro) | [Arch Linux AUR Packages](https://aur.archlinux.org/packages/?SeB=m&K=prurigro) diff --git a/tmux-italics-terminfo b/tmux-italics-terminfo new file mode 100755 index 0000000..4965c3c --- /dev/null +++ b/tmux-italics-terminfo @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +SRC_TERMINFO="screen-256color" +TMP_TERMINFO="/tmp/${SRC_TERMINFO}.terminfo" + +echo -n "Generating ${SRC_TERMINFO}-it... " + +[[ -d "${HOME}/.terminfo" ]] \ + || install -d "${HOME}/.terminfo/" +[[ -f "${HOME}/.terminfo/s/${SRC_TERMINFO}-it" ]] \ + && rm "${HOME}/.terminfo/s/${SRC_TERMINFO}-it" + +infocmp "$SRC_TERMINFO" | sed \ + -e 's/^screen[^|]*|[^,]*,/'${SRC_TERMINFO}'-it|'${SRC_TERMINFO}' with italics support,/' \ + -e 's/%?%p1%t;3%/%?%p1%t;7%/' \ + -e 's/smso=[^,]*,/smso=\\E[7m,/' \ + -e 's/rmso=[^,]*,/rmso=\\E[27m,/' \ + -e '$s/$/ sitm=\\E[3m, ritm=\\E[23m,/' > "$TMP_TERMINFO" +tic "$TMP_TERMINFO" + +rm "$TMP_TERMINFO" + +[[ ! -f "${HOME}/.terminfo/s/${SRC_TERMINFO}-it" ]] && echo "Error!" && exit 1 + +echo -e "Done!\n" +echo -e "Now in your tmux.conf, change:\n\n set-option -g default-terminal \"screen-256color\"\n\nto:\n\n set-option -g default-terminal \"screen-256color-it\""