Solved

Bash dialog menu - colors

Posted on 2007-04-04
17
2,820 Views
Last Modified: 2013-12-26
hello,
how can i put colors in dialog menus?

dialog  --title "some title" \
        --menu "\n        Use arrows - UP/DOWN \n\
        Press [Enter] to select\n" 20 40 10 \
        "1"       "Choose the psybnc port"\

how can i make 'Choose the psybnc port' green or something ?
thanx

0
Comment
Question by:rares_dumitrescu
  • 8
  • 6
  • 3
17 Comments
 

Author Comment

by:rares_dumitrescu
ID: 18850437
is it possible or not ?:)
and if it is .. how ?
0
 
LVL 84

Expert Comment

by:ozo
ID: 18856288
if you are on an ANSI terminal, try inserting <escape>[32m to turn on green <escape>[0m to turn off colours
0
 

Author Comment

by:rares_dumitrescu
ID: 18856951
dialog  --title "EvoPanel - getmuh v1.5" \
        --menu "\n        Use arrows - UP/DOWN.\n\
        Press [Enter] to select.\n" 21 45 10 \
        "GO"      "<escape>[32mStart installation"\

But it does not work .. it does not change the collor :|

0
 
LVL 84

Expert Comment

by:ozo
ID: 18857001
What does it do
How did you insert the <escape> character?
0
 

Author Comment

by:rares_dumitrescu
ID: 18857097
sorry i am bothering you so much, i am learning this things on the way
i am writing this scripts in ssh (putty) so .. how should i insert <escape>[32m ?
thanx
0
 
LVL 84

Expert Comment

by:ozo
ID: 18857144
perl -i -pe 's/<escape>/\e/g' script
would convert "<escape>" strings in script to  escape characters (which I can't cut and paste into this comment
0
 

Author Comment

by:rares_dumitrescu
ID: 18857198
that perl -i -pe .. made the script like this:
        "GO"      "^[[32mStart installation"\

so the <escape> was converted into ^[ .. but it still didn't change the color, when i execute it it just appears ^[[32mStart installation
0
 

Author Comment

by:rares_dumitrescu
ID: 18862789
anyone ? :D
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18881304
Do you have the dialog man page? I.e. do you get useful output from the command "man dialog"? Even if not, you can probably fina a man page from Google.
Dialog implements ANSI colours using embedded "\Z" sequences. You need to ensure the terminal type you set in the remote host matches putty's emulation.
0
 

Author Comment

by:rares_dumitrescu
ID: 18906725
yea, but i still want an answer on how to set collors :)
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18908948
The man page tells you how to do it - you should try reading it :)
In brief: include the option '--colors" on the command line. Then, to set the colour of a string, e.g. "\Zb\Z1" makes the following text bright red.
RTFM!
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18908958
When reading the man page, you can save yourself some time by searching for the string "color"
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18908968
dialog  --title "some title" \
        --menu "\n        Use arrows - UP/DOWN \n\
        Press [Enter] to select\n" 20 40 10 \
        "1"       "\Z2\ZZbChoose the psybnc port\Z0\ZB"\
0
 

Author Comment

by:rares_dumitrescu
ID: 19091868
it does not work :(
0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 19092276
OK I actually tried this one. The message colour is set by the number after the 2nd \Z- 2 for green as you originally suggested

dialog --colors --title "some title" --menu "\n        Use arrows - UP/DOWN\n       Press [Enter] to select\n" 20 40 10 "1" "\Zb\Z2Choose the psybnc port\Zn "
0
 

Author Comment

by:rares_dumitrescu
ID: 19123894
i dont know why, but the script does not work with --colors
the sistem is FreeBSD ..
0
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 19124046
This is the Linux topic area. If you are asking a FreeBSD question, you should be up front about it.
OK get the source for Linux dialog and build it under FreeBSD. Then it will understand --colors.
URL is http://invisible-island.net/dialog/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
countEvens challenge 2 74
fizzArray  challenge 1 58
My project did see openJDK that I installed. What could be the problem 7 122
Fibonacci challenge 11 109
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now