Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Send Bash Command

by Khen1950fx (Canon)
on Mar 03, 2010 at 06:57 UTC ( [id://826348]=note: print w/replies, xml ) Need Help??


in reply to Send Bash Command

For some reason or other, I've never thought about changing my prompt's color, but I have changed my CPAN prompt(see: Trick or Treat). Here's the easiest way that I know to change the bash prompt color using perl:
#!/usr/bin/perl use strict; use warnings; use ExtUtils::MakeMaker qw(prompt); prompt("export PS1=\e[0;31m\][\\u@\\H\\W\]\$\\e]m");
When you run it, it'll change the color to red, then it'll appear to hang. Actually, as with any command, bash is waiting for <enter>. To get back to your former color, just exit the terminal and start another one.

Replies are listed 'Best First'.
Re^2: Send Bash Command
by bichonfrise74 (Vicar) on Mar 03, 2010 at 19:03 UTC
    Out of curiosity, I tried your script in Linux OS and it seems to work. But if you do a 'ls', the red prompt turns back to black. Anyway, I think it is a good attempt.
      That's interesting. If you do a 'man ls', the man page turns to black. But when you 'q', it goes back to red:). I think that "prompt" is basically good for the first command. Then you need to switch to something like 'system' as in this work-around:
      #!/usr/bin/perl use strict; use warnings; use ExtUtils::MakeMaker qw(prompt); prompt("export PS1=\e[0;31m\][\\u@\\H\\W\]\$\\e]m"); system("ls");
      However, I like the idea of using 'ls' to return to the former color. It's quicker than restarting the terminal:).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://826348]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-20 01:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found