Re: [dev][st] Approach to adding -bg colour option to st

From: Aurélien Aptel <aurelien.aptel_AT_gmail.com>
Date: Tue, 26 Apr 2011 11:07:48 +0200

On Mon, Apr 25, 2011 at 12:03 PM, David Tweed <david.tweed_AT_gmail.com> wrote:
> (As
> background, I currenlty use a hacked aterm which changes the
> background colour according to the cwd. This works for changing hte
> colours, but the codebase and aterms behaviour on resize is poor, so
> long term I'd like to move to a better terminal codebase where I can
> hack in my colour functionality.)

The simplest way to achieve this is to implement the xterm esc and
script your shell prompt so it prints the esc followed by your regular
prompt.

Not tested:

settermbg() {
    echo -ne "\e]49;$1\a"
}

dirbg() {
    case $PWD in
        /mydir*) settermbg 1 ;;
        /foobar*) settermbg 42 ;;
        *) settermbg 0 ;;
    esac
}

# the \$(cmd) in PS1 is probably bash-only
# maybe PROMPT_COMMAND is more portable
PS1="\$(dirbg)\u \w $"
Received on Tue Apr 26 2011 - 11:07:48 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 26 2011 - 11:12:03 CEST