August 15th, 2011
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.
auto BufEnter * let &titlestring = s:MyTitle()
if &term =~ 'screen\(\.\(xterm\|rxvt\)\(-\(256\)\?color\)\?\)\?'
" Set the screen title using the vim "iconstring"."
auto BufEnter * let &iconstring = &titlestring
" Set the xterm title using the vim "titlestring"."
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:
Read the rest of this entry »
June 22nd, 2011
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:
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.
May 17th, 2011
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
Read the rest of this entry »
October 20th, 2010
While mobile devices (especially those with a GPS) have made people more aware of geolocation/geotagging, you don’t need a GPS in a device to make it location-aware, nor do you need to resort to IP-based reverse lookups. Location information can be made available on any network that has a DHCP server using the Location Configuration Information DHCP Option defined in RFC 3825. It makes sense: for most wired or wireless networks, the engineer responsible for setting up the DHCP server will know at the least where the server or AP is located, and maybe even static information about the locations of each terminal of a wired port.
The Option has a somewhat unorthodox binary format with non-power-of-2-width fixed point reals. To make generating the DHCP configuration statements easier, I developed a web-based RFC 3825 location configuration generation tool. It’s all client-side and even has a Google Maps preview of the location!
Copy the configuration to your local DHCP server, grab an appropriate geolocation library, and you’re ready to go! The tool generates a DHCP LCI Option for both dnsmasq and ISC’s dhcpd.
Other lessons: Google Maps is not highly accurate.