Window titles in screen and urxvt, from vim

I previously posted about generating title escapes for screen and rxvt-unicode from zsh. I’ve since worked on getting a consistent title from vim, too. It’s become complex enough that I’m spinning it out into a new post.

To set both titles from vim, use its termcap-title options to push the title to screen using the iconstring. When not running under screen, the right titlestring escapes will be inferred from terminfo.

set title
auto BufEnter * let &titlestring = s:MyTitle()

if &term =~ 'screen\(\.\(xterm\|rxvt\)\(-\(256\)\?color\)\?\)\?'
  " Set the screen title using the vim "iconstring"."
  set t_IS=^[k
  set t_IE=^[\
  set icon
  auto BufEnter * let &iconstring = &titlestring
  " Set the xterm title using the vim "titlestring"."
  set t_ts=^[]2;
  set t_fs=^G
endif

where the underlined characters are actual escapes input with ^V, not with literal carets.

As for generating a fancy title string like vim: there are some gotchas. The biggest is that vim does not preserve logical directory names, so getcwd() will resolve symlinks, leading to a different location string than generated by zsh’s %~. Rather than call pwd -L, we might as well unify the expansion syntax and call zsh. Of course, it’s nice to have a fallback, too:

Continue reading “Window titles in screen and urxvt, from vim”

Disabling hyphen substitution in Adium

By default Adium replaces two hyphens with an em-dash in text you type or paste. This leads to subtly confusing behaviour when pasting commands:

foo --bar

becomes “foo —bar”, which can look very similar to foo --bar if your contact is using a terminal that supports variable-width glyphs for exotic character points.

It’s a quick fix: stop double-hyphens being transformed to a long dash by right clicking the Adium input field, and unticking Substitutions > Smart Dashes from the menu.

window titles in screen and rxvt, from zsh

Recently I’ve been multiplexing work over many urxvt terminals: essential when you’re monitoring the logging output of several related binaries and managing several git branches related to each. The sensibilities of awesome have eased the window management, but I’ve become increasingly reliant on the window title to identify particular sessions. This is compounded one level further when I’m using screen; I want a useful identifier to show up in screen’s windowlist.

Getting nice prompts is a common need and there is plenty of information out there on setting your PS1, but for various reasons I’ve had problems finding a ‘nice’ setup that’s just worked exactly the way I’ve wanted it to with titles. Here are the pertinent parts of my working configuration:

  • I get the working directory and current command in the title
  • I get the title in the screen windowlist if running in screen
  • I get the same title in the WM_NAME of an rxvt or xterm, or the titlebar of an iTerm2, whether or not screen is involved

Continue reading “window titles in screen and rxvt, from zsh”