Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Putting Text in Window Title Bars (itworld.com)
2 points by abennett on Oct 8, 2009 | hide | past | favorite | 2 comments


The article mentions that the OS and shell matter, but I think this is mainly due to differences in the behavior of "echo". The "printf" program is at least consistent.

What actually matters for this is the declared terminal type, and the terminal program you're using.

In this case, the article uses sequences I don't recognize and doesn't specify what terminal is supposed to support them. None of their echoes work for me.

But perhaps a more common and supported approach is xterm:

- use a terminal program that supports and declares the right type, e.g. "xterm-color"

- use xterm-style title sequences, and "printf" to print them, such as:

  printf "\033]; `pwd` \007"


I use a little perl script, because it works everywhere I need it (and I suck at shell scripting ;))

    > cat `which title`
    #!/usr/bin/perl
    print(
        "\x1b",
        "]2;",
        join(' ', @ARGV),
        "\x7",
    );




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: