how do I specify color in custom status scripts?

Asked by Dr Paul Brewer

The man page for 2.71 says, under custom, "the indicator will be displayed in the lower panel, in inverted colors to your current bg/fg scheme, unless you manually specify the colors in your script's output"

How does one manually specify colors in script output?

Let's say I've got a bash or a perl script in ~/.byobu/bin.... what should it print to be red, blue, green, yellow, orange?

Question information

Language:
English Edit question
Status:
Answered
For:
byobu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dr Paul Brewer (drpaulbrewer) said :
#1

OK so part of the answer -- at least for PERL -- is

use Term::ANSIColor;

see http://perl.active-venture.com/lib/Term/ANSIColor.html

However, if this won't work right all the time or there's a better way I'd love to hear it.

Revision history for this message
Hemanth (hemanth-hm) said :
#2

Use tput for bash :

tput Colour Capabilities

tput setab [1-7]

    Set a background colour using ANSI escape
tput setb [1-7]

    Set a background colour
tput setaf [1-7]

    Set a foreground colour using ANSI escape
tput setf [1-7]

    Set a foreground colour

Revision history for this message
Dr Paul Brewer (drpaulbrewer) said :
#3

Hmm.... turns out perl's Term::ANSIColor works for the app stand alone but not when it is in the status bar.......

Revision history for this message
Dustin Kirkland  (kirkland) said :
#4

You would do something like this:

kirkland@x200:~/.byobu/bin$ cat 10_foo
#!/bin/sh -e
printf "\005{= rw}foobar\005{-}"

Where \005 is the escape sequence. "rw" says red background, white foreground. And the "-" undoes your changes after your custom data has been printed.

See the screen(1) manpage for the color codes.

Cheers!

Can you help with this problem?

Provide an answer of your own, or ask Dr Paul Brewer for more information if necessary.

To post a message you must log in.