Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-16 Thread Greg Wooledge
On Fri, Dec 13, 2019 at 04:50:18PM -0600, David Wright wrote:
> > PS1='\u@\h $(date +"%d %b %Y %H:%M:%S") :\w\$ '
> 
> Could \D{format} not do that?

Oh, good catch.  I've... never used that before. ;-)  I scanned the
PROMPTING section of the man page too quickly and only saw
the \t \T \@ \A parts.

PS1='\u@\h \D{%d %b %Y %H:%M:%S} :\w\$ '



Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread Vipul
> if [ "$color_prompt" = yes ]; then
> 
> PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\$
> '

You forgot to add "\d", in PS1 value, that explains different behavior
of prompt in console and Guake.

May be, this could fix the problem


if [ "$color_prompt" = yes ]; then

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:
\d \t \[\033[01;34m\]\w\[\033[00m\$'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h: \d \t \w\$'
fi


Now, as Wooledge suggested, replace "\d \t" with "$(date +"%d %b %Y
%H:%M:%S")".



Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread David Wright
On Fri 13 Dec 2019 at 14:36:09 (-0500), Greg Wooledge wrote:
> On Fri, Dec 13, 2019 at 07:20:53PM +, shirish शिरीष wrote:
> > Can somebody share how can I have a common prompt which is ok both by
> > bash and guake ?
> 
> guake...?  No idea what that is.  apt-cache says it's a terminal.  So
> I'm just going to assume that it works like any other terminal -- bash
> runs inside it.  The prompt is displayed by bash.  Therefore, the "guake"
> part of the question can be ignored.
> 
> > which is not bad but I would like it to be something like this -
> > 
> > shirish@debian 14 Dec 2019 00:43:04 :~$
> 
> PS1='\u@\h $(date +"%d %b %Y %H:%M:%S") :\w\$ '
> 
> Bash actually has the ability to show the time in the prompt without
> calling date(1), but you asked for an unusual date format, so I had to
> resort to the command substitution.

Could \D{format} not do that? Mind you, I'm surprised a prompt
needs the month and year. I would have thought the day of the
week would be more useful.

Cheers,
David.



Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread Dan Ritter
shirish ??? wrote: 
> at bottom :-
> 
> On 13/12/2019, Dan Ritter  wrote:
> > shirish ??? wrote:
> >> Dear all,
> >>
> >> Can somebody share how can I have a common prompt which is ok both by
> >> bash and guake ?
> >>
> >> bash is -
> >>
> >> $ guake --version
> >> Guake Terminal: 3.6.3
> >> VTE: 0.58.2
> >> VTE runtime: 0.58.2
> >> Gtk: 3.24.13
> >>
> >
> > guake is a terminal, not a shell. What happens when you run
> > guake and then run bash inside it? Are there options for guake
> > to run bash as your shell automatically?
> 
> I dunno.

man guake ; look for ways to set the shell.

Google for docs.

Look for people who use guake -- perhaps at guake-project.org?

-dsr-



Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread shirish शिरीष
at bottom :-

On 13/12/2019, Dan Ritter  wrote:
> shirish ??? wrote:
>> Dear all,
>>
>> Can somebody share how can I have a common prompt which is ok both by
>> bash and guake ?
>>
>> bash is -
>>
>> $ guake --version
>> Guake Terminal: 3.6.3
>> VTE: 0.58.2
>> VTE runtime: 0.58.2
>> Gtk: 3.24.13
>>
>
> guake is a terminal, not a shell. What happens when you run
> guake and then run bash inside it? Are there options for guake
> to run bash as your shell automatically?
>
> -dsr-
>

I dunno.

I am on debian-mate and the only thing I know is that I have guake
turned on my startup application/terminal once I enter mate-session.

In guake preferences in Shell option it comes the default interpretor
as  but doesn't tell of a way so I can have it the way I
shared using the current date and time -

shirish@debian 14 Dec 2019 00:43:04 :~$

I am just using copying and pasting the time from before .

Any idea/advice would be nice. I would rather have guake be the way it
is and just have the prompt as I want it.

-- 
  Regards,
  Shirish Agarwal  शिरीष अग्रवाल
  My quotes in this email licensed under CC 3.0
http://creativecommons.org/licenses/by-nc/3.0/
http://flossexperiences.wordpress.com

E493 D466 6D67 59F5 1FD0 930F 870E 9A5B 5869 609C



Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread Greg Wooledge
On Fri, Dec 13, 2019 at 07:20:53PM +, shirish शिरीष wrote:
> Can somebody share how can I have a common prompt which is ok both by
> bash and guake ?

guake...?  No idea what that is.  apt-cache says it's a terminal.  So
I'm just going to assume that it works like any other terminal -- bash
runs inside it.  The prompt is displayed by bash.  Therefore, the "guake"
part of the question can be ignored.

> which is not bad but I would like it to be something like this -
> 
> shirish@debian 14 Dec 2019 00:43:04 :~$

PS1='\u@\h $(date +"%d %b %Y %H:%M:%S") :\w\$ '

Bash actually has the ability to show the time in the prompt without
calling date(1), but you asked for an unusual date format, so I had to
resort to the command substitution.



Re: how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread Dan Ritter
shirish ??? wrote: 
> Dear all,
> 
> Can somebody share how can I have a common prompt which is ok both by
> bash and guake ?
> 
> bash is -
> 
> $ guake --version
> Guake Terminal: 3.6.3
> VTE: 0.58.2
> VTE runtime: 0.58.2
> Gtk: 3.24.13
> 

guake is a terminal, not a shell. What happens when you run
guake and then run bash inside it? Are there options for guake
to run bash as your shell automatically?

-dsr-



how to have a common prompt in bash and guake so I can view date and time as part of prompt ?

2019-12-13 Thread shirish शिरीष
Dear all,

Can somebody share how can I have a common prompt which is ok both by
bash and guake ?

bash is -

$ bash -version
GNU bash, version 5.0.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ guake --version
Guake Terminal: 3.6.3
VTE: 0.58.2
VTE runtime: 0.58.2
Gtk: 3.24.13

my current prompt looks like -

shirish@debian:~$

which is not bad but I would like it to be something like this -

shirish@debian 14 Dec 2019 00:43:04 :~$

so at any point in time I know at a glance the date and time.

If I'm not mistaken it is this bit -


if [ "$color_prompt" = yes ]; then

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\$
'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\d\$'
fi

This is from .bashrc .

I have seen date --help and probably %b, %d, %H and %M would be
involved but how to make it so it looks the same in terminal emulation
as well as in guake.

Looking forward to answer/answers.

I have also put it up as
https://unix.stackexchange.com/questions/557054/how-to-have-common-prompt-with-date-and-time-in-bash-as-well-as-guake

so feel free to reply here or there. If you do reply on the list
please CC me the same.

-- 
  Regards,
  Shirish Agarwal  शिरीष अग्रवाल
  My quotes in this email licensed under CC 3.0
http://creativecommons.org/licenses/by-nc/3.0/
http://flossexperiences.wordpress.com

E493 D466 6D67 59F5 1FD0 930F 870E 9A5B 5869 609C



Re: Temporary color prompt in bash script

2019-09-03 Thread David Wright
On Tue 03 Sep 2019 at 14:20:11 (-0400), Greg Wooledge wrote:
> On Tue, Sep 03, 2019 at 01:07:08PM -0500, David Wright wrote:
> > Trap is designed to break the sequential flow of commands.
> > I can't see any reason to do that when the OP wants the
> > sequence:
> > 
> > execute a script
> > print a string
> 
> Are you actually able to discern the OP's desires?  I can't.  I found
> everything they said in this thread completely impenetrable.  At first
> I thought they wanted to write a script that would change the bash
> prompt by setting the PS1 variable

I thought that at first, too, which is why I posted some of my .bashrc
which is a sensible place to set it and is also sourced.

When it appeared they just wanted to print the red string in much
the same way as printing a string that "rings a bell", ie to attract
attention, then I posted the ";" example. The sequence quoted above
would work, but typing "print a string" while the script is
possibly printing output of its own is error-prone, which is why
$ execute a script ; print a string
is safer. And it prints regardless, unless you hit ^C in which case
it's unnecessary anyway.

If the OP wants a different solution, the ball is in their court
as far as I'm concerned: I think I quizzed them enough already.

> > If you make your screen narrow before you cut and paste, you won't end
> > up with this mess, but something instead like:
> > 
> >trap [-lp] [[arg] sigspec ...]
> >   The command arg is to  be  read  and
> >   executed  when  the  shell  receives
> >   signal(s) sigspec.  If arg is absent
> >   (and  there  is a single sigspec) or
> >   -, each specified signal is reset to
> >   its  original disposition (the value
> >   it had upon entrance to the  shell).
> 
> An improvement to be sure, but you're still omitting the part about EXIT
> which was, if I'm not mistaken, the entire purpose of bringing up 'trap'
> in this context.

man bash   is a heavy read at the best of times, and that posting made
it almost incomprehensible. I was only quoting the "newspaper column"
version to demonstrate its legibility, not its content.

I don't know quite what the point of quoting it was in any case. Bash
is packaged with man bash so we've all got it. And will it help the OP
without an example?

> *If* the OP's desire is "Whenever my script exits, whether it's by normal
> means or by crashing after an error, I want it to print the terminal
> sequence that will turn text red." then the solution would be:
> 
> #!/bin/bash
> trap 'tput setaf 1' EXIT
> ... rest of the script ...

That would have been a lot clearer.

> If the OP's desire is something else, then the answer will be something
> else, but we can't answer the question until we can figure out what the
> question is.

Cheers,
David.



Re: Temporary color prompt in bash script

2019-09-03 Thread Greg Wooledge
On Tue, Sep 03, 2019 at 01:07:08PM -0500, David Wright wrote:
> Trap is designed to break the sequential flow of commands.
> I can't see any reason to do that when the OP wants the
> sequence:
> 
> execute a script
> print a string

Are you actually able to discern the OP's desires?  I can't.  I found
everything they said in this thread completely impenetrable.  At first
I thought they wanted to write a script that would change the bash
prompt by setting the PS1 variable

> If you make your screen narrow before you cut and paste, you won't end
> up with this mess, but something instead like:
> 
>trap [-lp] [[arg] sigspec ...]
>   The command arg is to  be  read  and
>   executed  when  the  shell  receives
>   signal(s) sigspec.  If arg is absent
>   (and  there  is a single sigspec) or
>   -, each specified signal is reset to
>   its  original disposition (the value
>   it had upon entrance to the  shell).

An improvement to be sure, but you're still omitting the part about EXIT
which was, if I'm not mistaken, the entire purpose of bringing up 'trap'
in this context.

*If* the OP's desire is "Whenever my script exits, whether it's by normal
means or by crashing after an error, I want it to print the terminal
sequence that will turn text red." then the solution would be:

#!/bin/bash
trap 'tput setaf 1' EXIT
... rest of the script ...

If the OP's desire is something else, then the answer will be something
else, but we can't answer the question until we can figure out what the
question is.



Re: Temporary color prompt in bash script

2019-09-03 Thread David Wright
On Tue 03 Sep 2019 at 15:07:43 (+), Larry Dighera wrote:
>  On Mon, 02 Sep 2019 08:48:50 +0200, Computer Planet
> 
>  wrote:
> 
> >Is It possible to print of a string at the exit of a bash script?
> 
> Have a look at `man bash` and search for 'trap.'

Trap is designed to break the sequential flow of commands.
I can't see any reason to do that when the OP wants the
sequence:

execute a script
print a string

>  trap [-lp] [[arg] sigspec ...]
>               The command arg is to be read and executed when the
> shell receives signal(s) sigspec.  If arg is absent
>               (and  there  is a single sigspec) or -, each specified
> signal is reset to its original disposition (the

If you make your screen narrow before you cut and paste, you won't end
up with this mess, but something instead like:

   trap [-lp] [[arg] sigspec ...]
  The command arg is to  be  read  and
  executed  when  the  shell  receives
  signal(s) sigspec.  If arg is absent
  (and  there  is a single sigspec) or
  -, each specified signal is reset to
  its  original disposition (the value
  it had upon entrance to the  shell).

Cheers,
David.



Fw: Temporary color prompt in bash script

2019-09-03 Thread Larry Dighera
 On Mon, 02 Sep 2019 08:48:50 +0200, Computer Planet

 wrote:

>Is It possible to print of a string at the exit of a bash script?

Have a look at `man bash` and search for 'trap.'

 trap [-lp] [[arg] sigspec ...]
              The command arg is to be read and executed when the
shell receives signal(s) sigspec.  If arg is absent
              (and  there  is a single sigspec) or -, each specified
signal is reset to its original disposition (the
              value it had upon entrance to the shell).  If arg is the
null  string  the  signal  specified  by  each
              sigspec  is ignored by the shell and by the commands it
invokes.  If arg is not present and -p has been
              supplied, then the trap commands associated with each
sigspec are displayed.  If no arguments are  sup-
              plied  or  if  only  -p is given, trap prints the list
of commands associated with each signal.  The -l
              option causes the shell to print a list of signal names
and their corresponding numbers.  Each  sigspec
              is  either  a signal name defined in , or a
signal number.  Signal names are case insensitive
              and the SIG prefix is optional.  [...]  

Re: Temporary color prompt in bash script

2019-09-02 Thread David Wright
On Mon 02 Sep 2019 at 08:48:50 (+0200), Computer Planet wrote:
> Thanks guys, 
> but this is not the solution I'm looking for ...

It's always nice to get feedback on why, so that we're more likely
to understand similar questions in future. For example, you never
really explained whether "command no problem, write in red until exit
or reboot" was something you want (everything red, or just prompts
in red?) or something you don't want (nothing red after the one
string) and whether you rebooted to clear a problem demonstrate that
red prompts were lost (against your wishes). We don't read minds.

> Now, I ask the question in other terms:
> Is It possible to print of a string at the exit of a bash script?
> e.g.: user@mypc: # bash script has just finished! [prompt] 
> with the prompt that remains immediately after the string printed.
> 
> Thanks, as always, for reply.

Sure:

$ ./my-script ; echo -n "the string"

or:

$ ./my-script ; echo -n -e "\e[0;31mthe string\e[m"

if you want "the string" in red.

So, using cat to stand for your script, and sleep to stand for the
time it takes your script to run:

wren!david 12:46:59 ~ $ cat /etc/network/interfaces ; date ; sleep 5 ; echo -n 
-e "\e[0;31mthe string\e[m"
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

#
Mon Sep  2 12:47:01 CDT 2019
the stringwren!david 12:47:06 ~ $ 

Cheers,
David.



Re: Temporary color prompt in bash script

2019-09-02 Thread tomas
On Mon, Sep 02, 2019 at 09:30:44AM +0200, Thomas Schmitt wrote:
> Hi,
> 
> Computer Planet wrote:
> > Is It possible to print of a string at the exit of a bash script?
> > e.g.: user@mypc: # bash script has just finished! [prompt]
> > with the prompt that remains immediately after the string printed.
> 
> Do you mean something like this ?
> 
>   $ echo -n 'user@mypc: # bash script has just finished! '
>   user@mypc: # bash script has just finished! $

Yep, that's possibly the easiest option: doing the "painting"
from whithin the script and not from the enclosing shell.

Another avenue would be, since PS1 does shell expansion dynamically,
to embed some command à la $(foo) whithin PS1. How that command
communicates with your script is left as an exercise to the reader :)

To illustrate what I may have expressed poorly above, try

  export PS1='Today is $(date). Your wish is my command: '

Have fun :)
-- t


signature.asc
Description: Digital signature


Re: Temporary color prompt in bash script

2019-09-02 Thread Thomas Schmitt
Hi,

Computer Planet wrote:
> Is It possible to print of a string at the exit of a bash script?
> e.g.: user@mypc: # bash script has just finished! [prompt]
> with the prompt that remains immediately after the string printed.

Do you mean something like this ?

  $ echo -n 'user@mypc: # bash script has just finished! '
  user@mypc: # bash script has just finished! $

The string "$ " is the prompt as of shell variable PS1.
Note that you need to set PS1 in the dialog shell, not in the script,
because the setting in the script is not present any more when the
dialog shell prints its prompt after the script ended.


Have a nice day :)

Thomas



Re: Temporary color prompt in bash script

2019-09-02 Thread tomas
On Mon, Sep 02, 2019 at 08:48:50AM +0200, Computer Planet wrote:
> Thanks guys, 
> but this is not the solution I'm looking for ...
> Now, I ask the question in other terms:
> Is It possible to print of a string at the exit of a bash script?

Hm. You mean

  echo

Still a bit confused about where you are "in".

Cheers
-- t


signature.asc
Description: Digital signature


Re: Temporary color prompt in bash script

2019-09-02 Thread Computer Planet
Thanks guys, 
but this is not the solution I'm looking for ...
Now, I ask the question in other terms:
Is It possible to print of a string at the exit of a bash script?
e.g.: user@mypc: # bash script has just finished! [prompt] 
with the prompt that remains immediately after the string printed.

Thanks, as always, for reply.

> [...]
> 
> > You have to source the script instead of running it.
> 
> Yes, exactly.
> 
> > I'm not entirely clear about a new shell gets it's own env that
> > disappears when the shell exits thing, but try this:
> 
> It's not only a shell thing. It's a basic Unix process thing:
> child processes inherit (well, almost always) their parent's
> environment -- more precisely a copy of it. They can change
> their copy, but not the parent's. That's by design: lots of
> loosely coupled programs calling each other (and that's what
> Unix is, after all ;-) would degenerate into an unmaintainable
> mess otherwise...
> 
> > $ cat setps1
> > ##!/bin/bash
> > # can i change ps1 from a script?
> > echo "FOO = ${FOO}"
> > export FOO=BAR
> > echo "FOO now = ${FOO}"
> > export PS1='\[\e]0;\u@\h:
> > \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
> > #\[\033[91m\] '
> > 
> > $ export FOO=FOO
> > $ ./setps1
> > FOO = FOO
> > FOO now = BAR
> > $ echo $FOO
> > FOO
> > 
> > See?  FOO is back to it's pre ./setps1 value
> > 
> > Now try
> > $ source setps1
> 
> That's the way. There's a shorthand for "source", which is ".". So instead
> of doing
> 
>   source setps1
> 
> you can say
> 
>   . setps1
> 
> Cheers
> -- tomás
> 



Re: Temporary color prompt in bash script

2019-09-01 Thread tomas
On Sun, Sep 01, 2019 at 03:22:32PM -0400, Lee wrote:

[...]

> You have to source the script instead of running it.

Yes, exactly.

> I'm not entirely clear about a new shell gets it's own env that
> disappears when the shell exits thing, but try this:

It's not only a shell thing. It's a basic Unix process thing:
child processes inherit (well, almost always) their parent's
environment -- more precisely a copy of it. They can change
their copy, but not the parent's. That's by design: lots of
loosely coupled programs calling each other (and that's what
Unix is, after all ;-) would degenerate into an unmaintainable
mess otherwise...

> $ cat setps1
> ##!/bin/bash
> # can i change ps1 from a script?
> echo "FOO = ${FOO}"
> export FOO=BAR
> echo "FOO now = ${FOO}"
> export PS1='\[\e]0;\u@\h:
> \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
> #\[\033[91m\] '
> 
> $ export FOO=FOO
> $ ./setps1
> FOO = FOO
> FOO now = BAR
> $ echo $FOO
> FOO
> 
> See?  FOO is back to it's pre ./setps1 value
> 
> Now try
> $ source setps1

That's the way. There's a shorthand for "source", which is ".". So instead
of doing

  source setps1

you can say

  . setps1

Cheers
-- tomás


signature.asc
Description: Digital signature


Re: Temporary color prompt in bash script

2019-09-01 Thread Lee
On 9/1/19, Computer Planet  wrote:
> Hi guys!
> I'm trying, trying and trying but...
>
> How I Can put in hte end of a bash script this command:
> PS1="\[\e]0;\u@\h:
> \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
> #\[\033[91m\] "
> so that after finishing the script the prompt will write in red...?
>
> If I try in prompt # PS1="\[\e]0;\u@\h:
> \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
> #\[\033[91m\] "
> command no problem, write in red until exit or reboot.

You have to source the script instead of running it.

I'm not entirely clear about a new shell gets it's own env that
disappears when the shell exits thing, but try this:

$ cat setps1
##!/bin/bash
# can i change ps1 from a script?
echo "FOO = ${FOO}"
export FOO=BAR
echo "FOO now = ${FOO}"
export PS1='\[\e]0;\u@\h:
\w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
#\[\033[91m\] '

$ export FOO=FOO
$ ./setps1
FOO = FOO
FOO now = BAR
$ echo $FOO
FOO

See?  FOO is back to it's pre ./setps1 value

Now try
$ source setps1

Lee



Re: Temporary color prompt in bash script

2019-09-01 Thread David Wright
On Sun 01 Sep 2019 at 17:53:51 (+0200), Computer Planet wrote:
> Hi guys!
> I'm trying, trying and trying but...
> 
> How I Can put in hte end of a bash script this command:
> PS1="\[\e]0;\u@\h: 
> \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
>  #\[\033[91m\] "
> so that after finishing the script the prompt will write in red...?
> 
> If I try in prompt # PS1="\[\e]0;\u@\h: 
> \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
>  #\[\033[91m\] "
> command no problem, write in red until exit or reboot.

Rather than figure out what exactly you're putting into your bash
prompt, I'll just post mine, for my host that uses red, and let
you pick out anything you want.

Localcolor comes from a separate subfile. The warning is to remind
me that PS1 should be set at the *end* of .bashrc because some of
the subfiles identify themselves if PS1 is set. But you don't want
any output generated from those subfiles, though, if .bashrc is
running to initialise a non-interactive shell. The extra xterm item
is for labelling xterm's title bars.

--✄

Localcolor='\e[0;31m' # red

###
# Don't change PS1 until after this point because its empty value #
# prevents sourced files from writing output when non-interactive #
###

# tty in the title bar makes it easier to kill an xterm should it freeze.

export PROMPT_COMMAND='Myprompt="$? " && [ "$Myprompt" = "0 " ] && Myprompt=""'
case "$TERM" in
*xterm*)
export PROMPT_COMMAND+=" ; printf '%b' '\e]0;${HOSTNAME^^}  
$(tty)  ${HOSTNAME^^}\a'"
;;
esac

export PS1='\[\e[1;33;41m\]$Myprompt\['
export PS1+="$Localcolor"
export PS1+='\]\H!\u \t \w \$ \[\e[m\]'
unset Localcolor

--✄

Cheers,
David.



Temporary color prompt in bash script

2019-09-01 Thread Computer Planet
Hi guys!
I'm trying, trying and trying but...

How I Can put in hte end of a bash script this command:
PS1="\[\e]0;\u@\h: 
\w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
 #\[\033[91m\] "
so that after finishing the script the prompt will write in red...?

If I try in prompt # PS1="\[\e]0;\u@\h: 
\w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w
 #\[\033[91m\] "
command no problem, write in red until exit or reboot.

Thanks in advance for reply.



Re: Prompt do bash

2005-10-27 Thread João Salvatti
Valeu a todos, mas Bruno era realmente isso que eu pesquisava!!! vou
aplicar o patch e ver se funciona!!

Falow.

On 10/26/05, Bruno de Oliveira Schneider [EMAIL PROTECTED] wrote:
 On 10/26/05, João Salvatti wrote:
  já pesquisei na internet e em alguns tutoriais sobre o bash mas não
  consegui nada que realmente me ajudasse. Gostaria de saber se tem como
  alterar o indicado de posição (na verdade não sei o nome daquele
  negócio direito), mas vou exemplificar:
  [EMAIL PROTECTED]:~$ | -- esta barrinha ai que fica no xterm que
  conforme a gente vai digitando ela vai se movendo mostrando a nova
  posição da tela, acho que é o cursor da letra, não sei direito, mas
  gostaria de saber se tem como deixá-la igual nos consoles desse jeito:
  [EMAIL PROTECTED]:~$ _ -- agora ele esta embaixo. Tem como modificar
  isso no xterm.

 Esse negocinho que pisca e indica a posição do próximo caracter se
 chama cursor. A forma do cursor não tem nada a ver com bash ou com o
 prompt ou com a váriavel do bash que controla o prompt (PS1). A forma
 do cursor é definida pelo terminal.

 Fazendo uma busca rápida no google, achei o seguinte:

 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=299439

 que mostra que normalmente não é possível fazer o que você quer no
 xterm, mas já existe um patch para isso e então esta opção deverá
 estar disponível nas próximas versões do xterm.

 Eu uso o rxvt que aparentemente já permite fazer isso na última versão
 (que ainda não foi para o Debian Etch).

 Talvez seja possível fazer isso em algum outro terminal gráfico... É
 preciso pesquisar para descobrir.

 --
 Bruno de Oliveira Schneider
 http://www.dcc.ufla.br/~bruno/




--
João Salvatti
Undergraduating in Computer Science
Federal University of Para - UFPA
web: http://salvatti.expert.com.br
e-mail: [EMAIL PROTECTED]



Re: Prompt do bash

2005-10-27 Thread Datacom - Tavares
On Wed, 2005-10-26 at 10:23 -0300, João Salvatti wrote:
 Olá pessoal da lista,
 
 já pesquisei na internet e em alguns tutoriais sobre o bash mas não
 consegui nada que realmente me ajudasse. Gostaria de saber se tem como
 alterar o indicado de posição (na verdade não sei o nome daquele
 negócio direito), mas vou exemplificar:
 [EMAIL PROTECTED]:~$ | -- esta barrinha ai que fica no xterm que
 conforme a gente vai digitando ela vai se movendo mostrando a nova
 posição da tela, acho que é o cursor da letra, não sei direito, mas
 gostaria de saber se tem como deixá-la igual nos consoles desse jeito:
 [EMAIL PROTECTED]:~$ _ -- agora ele esta embaixo. Tem como modificar
 isso no xterm.
 
 Falow.
 
 --
 João Salvatti
 Undergraduating in Computer Science
 Federal University of Para - UFPA
 web: http://salvatti.expert.com.br
 e-mail: [EMAIL PROTECTED]
 
 


Uma curiosidade..
Qual a vantagem disto? :)


-- 

[]
JA Tavares


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Prompt do bash

2005-10-27 Thread pmarc
 Uma curiosidade..
 Qual a vantagem disto? :)

é k o negocim que fika piskandu imbaixo da tela é taum bunitim oOOo

Ainda bem que o brasil é um estado de direito senão gente como eu
estaria apodrecendo em alguma cadeia.
--
Paulo Marcondes
http://rj.debianbrasil.org



Prompt do bash

2005-10-26 Thread João Salvatti
Olá pessoal da lista,

já pesquisei na internet e em alguns tutoriais sobre o bash mas não
consegui nada que realmente me ajudasse. Gostaria de saber se tem como
alterar o indicado de posição (na verdade não sei o nome daquele
negócio direito), mas vou exemplificar:
[EMAIL PROTECTED]:~$ | -- esta barrinha ai que fica no xterm que
conforme a gente vai digitando ela vai se movendo mostrando a nova
posição da tela, acho que é o cursor da letra, não sei direito, mas
gostaria de saber se tem como deixá-la igual nos consoles desse jeito:
[EMAIL PROTECTED]:~$ _ -- agora ele esta embaixo. Tem como modificar
isso no xterm.

Falow.

--
João Salvatti
Undergraduating in Computer Science
Federal University of Para - UFPA
web: http://salvatti.expert.com.br
e-mail: [EMAIL PROTECTED]



Re: Prompt do bash

2005-10-26 Thread Marcelo Loiaco
procura por set prompt
prompt é uma variavel de ambiente... que faz exatamente isso...

vc vai achar um monte de coisa!!
ae vc achando coloca ele no teu ~/.bashrc

ae posta aqui o resultado...

t+

- Original Message -
From: João Salvatti [EMAIL PROTECTED]
To: debian-user-portuguese@lists.debian.org
Sent: Wednesday, October 26, 2005 11:23 AM
Subject: Prompt do bash


Olá pessoal da lista,

já pesquisei na internet e em alguns tutoriais sobre o bash mas não
consegui nada que realmente me ajudasse. Gostaria de saber se tem como
alterar o indicado de posição (na verdade não sei o nome daquele
negócio direito), mas vou exemplificar:
[EMAIL PROTECTED]:~$ | -- esta barrinha ai que fica no xterm que
conforme a gente vai digitando ela vai se movendo mostrando a nova
posição da tela, acho que é o cursor da letra, não sei direito, mas
gostaria de saber se tem como deixá-la igual nos consoles desse jeito:
[EMAIL PROTECTED]:~$ _ -- agora ele esta embaixo. Tem como modificar
isso no xterm.

Falow.

--
João Salvatti
Undergraduating in Computer Science
Federal University of Para - UFPA
web: http://salvatti.expert.com.br
e-mail: [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: Prompt do bash

2005-10-26 Thread Leandro Ferreira
No dia 26/10/2005 às 10:23,
João Salvatti [EMAIL PROTECTED] escreveu:

 já pesquisei na internet e em alguns tutoriais sobre o bash mas não
 consegui nada que realmente me ajudasse. Gostaria de saber se tem como
 alterar o indicado de posição (na verdade não sei o nome daquele
 negócio direito), mas vou exemplificar:
 [EMAIL PROTECTED]:~$ | -- esta barrinha ai que fica no xterm que
 conforme a gente vai digitando ela vai se movendo mostrando a nova
 posição da tela, acho que é o cursor da letra, não sei direito, mas
 gostaria de saber se tem como deixá-la igual nos consoles desse jeito:
 [EMAIL PROTECTED]:~$ _ -- agora ele esta embaixo. Tem como modificar
 isso no xterm.
 

Mude no seu ~/.bashrc o valor da variável PS1. Outro dia um colega da
lista postou uma mensagem sobre isso.

Digite man bash e procure por PS1, tem uma enorme lista de argumentos.
Alguns exemplos:


 \u the username of the current user
 \v the version of bash (e.g., 2.00)
 \V the release of bash, version + patch level (e.g., 2.00.0)
 \w the current working directory, with $HOME abbreviated with a tilde
 \W the basename of the current working directory, with $HOME abbreviated 
with a tilde
 \! the history number of this command
 \# the command number of this command

Um abraço

Leandro

--
 (@_   Leandro Padilha Ferreira - http://androle.pro.br
 //\
 V_/_  Linux user #237.744 - GPG ID: A7FB969E
 
---
O futuro e a unica propriedade de que os senhores concedem 
de boa vontade aos escravos.
-- Albert Camus 


signature.asc
Description: Digital signature


Re: Prompt do bash

2005-10-26 Thread Bruno de Oliveira Schneider
On 10/26/05, João Salvatti wrote:
 já pesquisei na internet e em alguns tutoriais sobre o bash mas não
 consegui nada que realmente me ajudasse. Gostaria de saber se tem como
 alterar o indicado de posição (na verdade não sei o nome daquele
 negócio direito), mas vou exemplificar:
 [EMAIL PROTECTED]:~$ | -- esta barrinha ai que fica no xterm que
 conforme a gente vai digitando ela vai se movendo mostrando a nova
 posição da tela, acho que é o cursor da letra, não sei direito, mas
 gostaria de saber se tem como deixá-la igual nos consoles desse jeito:
 [EMAIL PROTECTED]:~$ _ -- agora ele esta embaixo. Tem como modificar
 isso no xterm.

Esse negocinho que pisca e indica a posição do próximo caracter se
chama cursor. A forma do cursor não tem nada a ver com bash ou com o
prompt ou com a váriavel do bash que controla o prompt (PS1). A forma
do cursor é definida pelo terminal.

Fazendo uma busca rápida no google, achei o seguinte:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=299439

que mostra que normalmente não é possível fazer o que você quer no
xterm, mas já existe um patch para isso e então esta opção deverá
estar disponível nas próximas versões do xterm.

Eu uso o rxvt que aparentemente já permite fazer isso na última versão
(que ainda não foi para o Debian Etch).

Talvez seja possível fazer isso em algum outro terminal gráfico... É
preciso pesquisar para descobrir.

--
Bruno de Oliveira Schneider
http://www.dcc.ufla.br/~bruno/



???current directory in prompt in bash???

1998-12-08 Thread Rich Hartman
Is there a way to have bash include the current directory in the 
prompt of bash? Actually, let me re-phrase that my root account 
DOES include the current directory in the the prompt, but I have no 
idea why or how... I've tried to copy my root's .bash_profile to my 
regular-user's .bash_profile, but it still doesn't work any 
ideas?

Thanks in advance

Rich


Re: ???current directory in prompt in bash???

1998-12-08 Thread David Z. Maze
Rich Hartman [EMAIL PROTECTED] writes:
Rich Is there a way to have bash include the current directory in the 
Rich prompt of bash?

Yes.  See bash(1), under PROMPTING.

-- 
 _
/ \   Dad was reading a book called
|  David Maze | _Schroedinger's Kittens_.  Asexual
| [EMAIL PROTECTED]   |  reproduction?  Only one cat is in the box.
| http://donut.mit.edu/dmaze/ |   -- Abra Mitchell
\_/


Re: ???current directory in prompt in bash???

1998-12-08 Thread Stephan Engelke
Hi Rich,

On Tue, Dec 08, 1998 at 08:38:00AM +, Rich Hartman wrote:
 Is there a way to have bash include the current directory in the 
 prompt of bash? Actually, let me re-phrase that my root account 
 DOES include the current directory in the the prompt, but I have no 
 idea why or how... I've tried to copy my root's .bash_profile to my 
 regular-user's .bash_profile, but it still doesn't work any 
 ideas?

something along the lines of 
export PS1=\\w \$ 
is your friend.  the excape-sequence \w produces the current working
directory if I am not mistaken.
Check man bash for more details (search for PS1).
Also, check root's .bashrc, most likely the prompt variable is defined here.
on my Hamm-Systems .bashrc sources .bash_profile.


So long,
Stephan
-- 
Stephan Engelke[EMAIL PROTECTED]
 *** Coffee not found: Operator halted ***


Re: ???current directory in prompt in bash???

1998-12-08 Thread Kent West
At 08:38 AM 12/8/1998 +, Rich Hartman wrote:
Is there a way to have bash include the current directory in the 
prompt of bash? Actually, let me re-phrase that my root account 
DOES include the current directory in the the prompt, but I have no 
idea why or how... I've tried to copy my root's .bash_profile to my 
regular-user's .bash_profile, but it still doesn't work any 
ideas?

Thanks in advance

Rich

Yes. In your .bash_profile file, include a couple of lines like:
PS1='\h:s[\u] $PWD \$ '
export PS1

This sets the prompt so that it displays the computer's hostname (\h),
the shell you're using (\s), the name of the logged-in user (\u), and the
current working directory ($PWD) followed by a $ prompt. Some of the more
knowledgeable people might make suggestions for making this more
bullet-proof; I think the system may get confused as to the length of the
prompt which might cause wrapping problems etc unless other codes are
thrown in, etc. However, this prompt works for me.

You can experiment simply by typing at the prompt something like:
export PS1=$PWD
and etc, then add the desired line to .bash_profile for future logins.

You can also take a look at man console_codes (or search in
www.linuxgazette.com for 2-cent tips concerning adding color to your
prompt) if you want to do such things as adding color to your prompt.

For example, on another machine I've got a prompt that looks like:
PS1=\[\n\t\]\n^[[44;01;33m\h[\u]:\$PWD^[[m\] 
which gives me the current time followed by a newline followed by the same
prompt mentioned above with yellow letters on a blue background. The ^[ is
a special escape sequence; I'm sorry, I don't remember how to enter that
sequence, maybe Ctrl-[ does it. At any rate, not all editors will let you
enter that sequence, but I did mine in vi.


Re: ???current directory in prompt in bash???

1998-12-08 Thread Mitch Blevins
Rich Hartman wrote:
 Is there a way to have bash include the current directory in the 
 prompt of bash? Actually, let me re-phrase that my root account 
 DOES include the current directory in the the prompt, but I have no 
 idea why or how... I've tried to copy my root's .bash_profile to my 
 regular-user's .bash_profile, but it still doesn't work any 
 ideas?

See other messages about how to add the \w to PS1, but what may
be getting you is that the .bash_profile will not be read in unless
you specifically have your shell set to /bin/bash in your /etc/passwd,
rather than getting it thru the symlink from /bin/sh

-Mitch


Re: ???current directory in prompt in bash???

1998-12-08 Thread wtopa

Subject: ???current directory in prompt in bash???
Date: Tue, Dec 08, 1998 at 08:38:00AM +

In reply to:[EMAIL PROTECTED]

Quoting [EMAIL PROTECTED]([EMAIL PROTECTED]):
 
 Is there a way to have bash include the current directory in the 
 prompt of bash? Actually, let me re-phrase that my root account 
 DOES include the current directory in the the prompt, but I have no 
 idea why or how... I've tried to copy my root's .bash_profile to my 
 regular-user's .bash_profile, but it still doesn't work any 
 ideas?
 
 Thanks in advance
 
 Rich
 

See 'man bash' for all the gory details.  Here is my prompt which is
set in .bash_profile.

# for normal everyday use use this prompt string
V_TERM=`tty`
export PS1=\[`setterm -foreground green`\]VT${V_TERM##/dev/tty} \u-Slink:\w# 


The sequence \u-Slink:\w#gives me  VT2 root-Slink:~#  as the
prompt.


I seem to recall that doing it this way violates Debian Policy or some
such thing.  So Beware of the Policy police.

HTH

-- 
Micro Credo:
 Never trust a computer bigger than you can lift.
___
Wayne T. Topa [EMAIL PROTECTED]


Re: ???current directory in prompt in bash???

1998-12-08 Thread wtopa

Subject: Re: ???current directory in prompt in bash???
Date: Tue, Dec 08, 1998 at 11:29:18AM -0500

In reply to:Wayne Topa

Quoting Wayne Topa([EMAIL PROTECTED]):
 
   Subject: ???current directory in prompt in bash???
   Date: Tue, Dec 08, 1998 at 08:38:00AM +
 
 In reply to:[EMAIL PROTECTED]
 
 Quoting [EMAIL PROTECTED]([EMAIL PROTECTED]):
  
  Is there a way to have bash include the current directory in the 
  prompt of bash? Actually, let me re-phrase that my root account 
  DOES include the current directory in the the prompt, but I have no 
  idea why or how... I've tried to copy my root's .bash_profile to my 
  regular-user's .bash_profile, but it still doesn't work any 
  ideas?
  
  Thanks in advance
  
  Rich
  
 
 See 'man bash' for all the gory details.  Here is my prompt which is
 set in .bash_profile.
 
 # for normal everyday use use this prompt string
 V_TERM=`tty`
 export PS1=\[`setterm -foreground green`\]VT${V_TERM##/dev/tty} 
 \u-Slink:\w# 
 
 
 The sequence \u-Slink:\w#gives me  VT2 root-Slink:~#  as the
 prompt.
 
 
 I seem to recall that doing it this way violates Debian Policy or some
 such thing.  So Beware of the Policy police.

Woops, sorry. Just recalled that I had been told by the SUSE policy
police that this was the wrong way to do it, NOT Debian.  

That was reason #45 for dropping SUSE in favor of Debian.  Sorry for
the brain drain.

 
 HTH
 
 -- 
 Micro Credo:
  Never trust a computer bigger than you can lift.
 ___
 Wayne T. Topa [EMAIL PROTECTED]

-- 
Unquestionably, there is progress.  The average American now pays out
twice as much in taxes as he formerly got in wages.
-- H. L. Mencken
___
Wayne T. Topa [EMAIL PROTECTED]


Re: Prompt in Bash [fixed]

1997-09-07 Thread Rob Browning
Will Lowe [EMAIL PROTECTED] writes:

 Yup,  kill the eval and life is good.  Thanks,  Mr. Browning.

You're welcome, but sheesh, call me Rob :

One final word for those who were following this thread.

This

  if [ ${PS1:-UNSET} = UNSET ]

should have been

  if [ ${PS1:-UNSET} = UNSET ]

Without the quotes, you can get problems when you have a prompt with
escape characters.

-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Will Lowe
If I do this:

On 5 Sep 1997, Rob Browning wrote:

 set_titlebar () { echo -n ]2;$*; }
 export -f set_titlebar

And then someplace call set_titlebar,  I just get ^[]2;$*^G
echoed to my terminal.  It doesn't ever set the titlebar.  I'm using rxvt.
Suggestions?
Will

---
 [EMAIL PROTECTED]
   [EMAIL PROTECTED]
[EMAIL PROTECTED]
 http://www.cis.udel.edu/~lowe/
  For PGP Public Key,  visit my website.
---


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Rob Browning
Will Lowe [EMAIL PROTECTED] writes:

 If I do this:
 
 On 5 Sep 1997, Rob Browning wrote:
 
  set_titlebar () { echo -n ]2;$*; }
  export -f set_titlebar
 
   And then someplace call set_titlebar,  I just get ^[]2;$*^G
 echoed to my terminal.  It doesn't ever set the titlebar.  I'm using rxvt.
 Suggestions?

Uhm, oops, my fault.  There were 8-bit characters in that script that
I didn't mention.  I don't know what you saw, but what you should have
seen was:

set_titlebar () { echo -n ^[]2;$*^G; }

Here ^[ and ^G actually have to be real control characters not a ^
followed by a G or [.  To type these into a file in emacs, you can use
C-q C-g for ^G and C-q C-[ for ^[.  If this doesn't make sense to you,
ask and I'll explain in more detail.  You can get the same effect from
a bash prompt with C-q Cv:

  quoted-insert (C-q, C-v)
  Add  the  next  character that you type to the line
  verbatim.  This is how to  insert  characters  like
  C-q, for example. 

Let me know if this doesn't help.
-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Michael Harnois
Jens B. Jorgensen [EMAIL PROTECTED] writes:

 Gonzalo A. Diethelm wrote:
  
  A while ago, somebody in this forum posted how to make the current
  working directory appear on the title bar in an xterm. I lost that
  article somehow; could the author repost it? Thanks in advance...
  
 
 Well, you should have RTFMpage, but here's the excerpt you want:

I'm a bit confused. I read the excerpt from the bash manpage you
quoted a number of times, but I couldn't find any reference at all
there as to the workings of the xterm titlebar, which was the man's
question ...

-- 
 Michael D. Harnois, Redeemer Lutheran Church, Washburn, IA
 [EMAIL PROTECTED]  [EMAIL PROTECTED]
 Few sinners are saved after the first 20 minutes of 
  a sermon.  --Mark Twain


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Michael Harnois
Since you're providing enlightenment ... I ran into a problem when I
tried to modify your script for my own preferences. Specifically, when 
I tried to change the value of PS1 to give a colorized prompt. The
string I began with was

PS1=\\[\\e[1;31m\\]\h:\\[\\e[0m\\]\\[\\e[1;34m\\]\\w\\[\\e[0m\\] $ 

This string works find in a straight .bashrc. However, when I use it 
in your file, it works fine on a login shell. When I start a subshell, 
though, I get

[: too many arguments

Thinking I must be doing something terribly stupid, I poked and
prodded that string every way I could think of, but the same result
persisted. 

-- 
 Michael D. Harnois, Redeemer Lutheran Church, Washburn, IA
 [EMAIL PROTECTED]  [EMAIL PROTECTED]
 Few sinners are saved after the first 20 minutes of 
  a sermon.  --Mark Twain


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Will Lowe
On 5 Sep 1997, Rob Browning wrote:

 Will Lowe [EMAIL PROTECTED] writes:
 
   set_titlebar () { echo -n ]2;$*; }

 Here ^[ and ^G actually have to be real control characters not a ^

Ok,  now I get a 
[EMAIL PROTECTED]:~: command not found

[EMAIL PROTECTED]:~ is what should end up in the titlebar,  but it's instead
somehow being evaluated.  Any other clues?
Will

---
 [EMAIL PROTECTED]
   [EMAIL PROTECTED]
[EMAIL PROTECTED]
 http://www.cis.udel.edu/~lowe/
  For PGP Public Key,  visit my website.
---


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Rob Browning
Michael Harnois [EMAIL PROTECTED] writes:

 Since you're providing enlightenment ...

Don't know if I'd go that far :

 This string works find in a straight .bashrc. However, when I use it 
 in your file, it works fine on a login shell. When I start a subshell, 
 though, I get

I'd have to see the file to be sure, but my guess is that it's not the
prompt string, but rather a problem with test (i.e. the [ command).
Email me your .bashrc, and send me the result of ls -l .bash*.

-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Rob Browning
Will Lowe [EMAIL PROTECTED] writes:

 Ok,  now I get a 
 [EMAIL PROTECTED]:~: command not found
 
 [EMAIL PROTECTED]:~ is what should end up in the titlebar,  but it's instead
 somehow being evaluated.  Any other clues?

Email me a snippet that causes the problem, and I'll check it out.  If
a small snippet won't cause it, send me your .bashrc, and the output
of 'ls -l .bash*'.

Thanks
-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Gonzalo A. Diethelm
Rob, thanks a lot for your script. I think there is a small glitch,
though:

  if [ ${PS1:-UNSET} = UNSET ]
  then
   INTERACTIVE_SHELL=F
  else
   INTERACTIVE_SHELL=T
  
if [ $TERM = xterm -o $TERM = rxvt ]
then
  set_titlebar () { echo -n ]2;$*; }
  export -f set_titlebar
  
  my_dirname () { 
if [ ${PWD#$HOME} != $PWD ]
then
 echo '~'${PWD#$HOME}
else
 echo $PWD
fi
  }
  export -f my_dirname

This effectively returns the current working directory, taking care to
replace the $HOME prefix with a single `~`.

  export PS1='\n\!\$ '
  export PROMPT_COMMAND='eval set_titlebar [EMAIL PROTECTED]:`my_dirname`'

When I did this, the title bar showed the full path, without replacing
$HOME with a '~' character. I got rid of the eval, and things were
fine.

else
  export PS1='[EMAIL PROTECTED]:\w\n\!\$ '
fi 
  fi
  
  if [ ${BASH_INITIALIZED} != Yes ]
  then
   export BASH_INITIALIZED=Yes
  
# Do other stuff here that should only happen once, and be
# inherited by sub-shells.
  
  fi

  Rob

-- 
Gonzalo A. Diethelm G.
[EMAIL PROTECTED]


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-06 Thread Rob Browning
Gonzalo A. Diethelm [EMAIL PROTECTED] writes:

 Rob, thanks a lot for your script. I think there is a small glitch,
 though:

Not surprised :

   export PS1='\n\!\$ '
   export PROMPT_COMMAND='eval set_titlebar [EMAIL 
 PROTECTED]:`my_dirname`'
 
 When I did this, the title bar showed the full path, without replacing
 $HOME with a '~' character. I got rid of the eval, and things were
 fine.

Hmm.  I have no idea now why that eval's there.  I must have thought I
needed it at some point (or I copied a pasted something I shouldn't
have), but things seem to work fine without it.

The eval might also explain why others were getting the command not
found errors, but if so, I don't understand why I wasn't getting them
here too.

Thanks for pointing that out.
-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash [fixed]

1997-09-06 Thread Will Lowe
On 6 Sep 1997, Rob Browning wrote:

 Gonzalo A. Diethelm [EMAIL PROTECTED] writes:
 
  Rob, thanks a lot for your script. I think there is a small glitch,
  though:
  export PROMPT_COMMAND='eval set_titlebar [EMAIL PROTECTED]:`my_dirname`'

Yup,  kill the eval and life is good.  Thanks,  Mr. Browning.

Will

---
 [EMAIL PROTECTED]
   [EMAIL PROTECTED]
[EMAIL PROTECTED]
 http://www.cis.udel.edu/~lowe/
  For PGP Public Key,  visit my website.
---


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Gonzalo A. Diethelm
A while ago, somebody in this forum posted how to make the current
working directory appear on the title bar in an xterm. I lost that
article somehow; could the author repost it? Thanks in advance...

On Aug 22, 1997, at 22:44, Dave Cinege wrote:
  On Fri, 22 Aug 1997 12:32:35 -0300 (EST), Daniel Doro Ferrante wrote:
  Does anybody know how do I change colors in a bash prompt. I can
  do it in tcsh, but no succes with bash... (even after reading the man).
  
  #b/w prompt
  #PS1=\\h\\$ \\u [\\w] 
  
  #Pretty color prompt. Comment it out if your terminal doesn't support ANSI co
  
  #We must encase the ANSI codes in \[ and \] or else bash will have line lengt
  #problems. \e is a pretty form of the raw escape sequence
  PS1=\\[\\e[1;31m\\]\\h\\[\\e[0m\\]\\$ \\u [\\[\\e[1;34m\\]\\w\\[\\e[0m\\]] 

-- 
Gonzalo A. Diethelm G.
[EMAIL PROTECTED]


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Rob Browning

Ask and ye shall receive : This is a cut-down version of my bashrc.
It also shows a trick to get around the problem with some shells
actually being login shells, but not calling .bash_login (i.e. X login
shells).  I just symlink my .bash_login to my .bashrc, and let .bashrc
handle figuring out what kind of shell it is (see BASH_INITIALIZED
below).

if [ ${PS1:-UNSET} = UNSET ]
then
INTERACTIVE_SHELL=F
else
INTERACTIVE_SHELL=T

  if [ $TERM = xterm -o $TERM = rxvt ]
  then
set_titlebar () { echo -n ]2;$*; }
export -f set_titlebar

my_dirname () { 
  if [ ${PWD#$HOME} != $PWD ]
  then
  echo '~'${PWD#$HOME}
  else
  echo $PWD
  fi
}
export -f my_dirname

export PS1='\n\!\$ '
  export PROMPT_COMMAND='eval set_titlebar [EMAIL 
PROTECTED]:`my_dirname`'
  else
export PS1='[EMAIL PROTECTED]:\w\n\!\$ '
  fi 
fi

if [ ${BASH_INITIALIZED} != Yes ]
then
export BASH_INITIALIZED=Yes

  # Do other stuff here that should only happen once, and be
  # inherited by sub-shells.

fi

-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Jens B. Jorgensen
Gonzalo A. Diethelm wrote:
 
 A while ago, somebody in this forum posted how to make the current
 working directory appear on the title bar in an xterm. I lost that
 article somehow; could the author repost it? Thanks in advance...
 

Well, you should have RTFMpage, but here's the excerpt you want:

   a command.  Bash allows these prompt strings  to  be  cus­
   tomized by inserting a number of backslash-escaped special
   characters that are decoded as follows:
  \t the current time in HH:MM:SS format
  \d the date  in  Weekday  Month  Date  format
 (e.g., Tue May 26)
  \n newline
  \s the  name  of  the shell, the basename of $0
 (the portion following the final slash)
  \w the current working directory
  \W the basename of the current  working  direc­
 tory
  \u the username of the current user
  \h the hostname
  \# the command number of this command
  \! the history number of this command
  \$ if  the effective UID is 0, a #, otherwise a
 $
  \nnn   the character  corresponding  to  the  octal
 number nnn
  \\ a backslash
  \[ begin a sequence of non-printing characters,
 which could be used to embed a terminal con­
 trol sequence into the prompt
  \] end a sequence of non-printing characters


-- 
Jens B. Jorgensen
[EMAIL PROTECTED]


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Lawrence
Is it possible to do it in tcsh?

Rob Browning wrote:
 
 Ask and ye shall receive : This is a cut-down version of my bashrc.
 It also shows a trick to get around the problem with some shells
 actually being login shells, but not calling .bash_login (i.e. X login
 shells).  I just symlink my .bash_login to my .bashrc, and let .bashrc
 handle figuring out what kind of shell it is (see BASH_INITIALIZED
 below).
 
 if [ ${PS1:-UNSET} = UNSET ]
 then
 INTERACTIVE_SHELL=F
 else
 INTERACTIVE_SHELL=T
 
   if [ $TERM = xterm -o $TERM = rxvt ]
   then
 set_titlebar () { echo -n ]2;$*; }
 export -f set_titlebar
 
 my_dirname () {
   if [ ${PWD#$HOME} != $PWD ]
   then
   echo '~'${PWD#$HOME}
   else
   echo $PWD
   fi
 }
 export -f my_dirname
 
 export PS1='\n\!\$ '
   export PROMPT_COMMAND='eval set_titlebar [EMAIL 
 PROTECTED]:`my_dirname`'
   else
 export PS1='[EMAIL PROTECTED]:\w\n\!\$ '
   fi
 fi
 
 if [ ${BASH_INITIALIZED} != Yes ]
 then
 export BASH_INITIALIZED=Yes
 
   # Do other stuff here that should only happen once, and be
   # inherited by sub-shells.
 
 fi
 
 --
 Rob
 
 --
 TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
 [EMAIL PROTECTED] .
 Trouble?  e-mail to [EMAIL PROTECTED] .


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Rob Browning
Jens B. Jorgensen [EMAIL PROTECTED] writes:

 Well, you should have RTFMpage, but here's the excerpt you want:

That seems a little over-harsh.

a command.  Bash allows these prompt strings  to  be  cus­
tomized by inserting a number of backslash-escaped special
characters that are decoded as follows:

[...]

This list of bash escapes doesn't tell them the sequence of characters
that has to be sent to an *xterm* to set the title-bar, which is what
they really need to know.  I had to dig around for a while before I
figured that out.  Maybe the rxvt man page has been improved...

They also have to figure out the BASH_PROMPT variable if they want the
~ cleanup, and several other little tidbits that take quite a while
to pull together.  I certainly don't begurdge saving someone else the
time to figure all that out.  Others have certainly done the same for
me innumerable times.
--
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] .
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Rob Browning
Lawrence [EMAIL PROTECTED] writes:

 Is it possible to do it in tcsh?

Good question.  I've never used tcsh, but I would guess so.  The key
thing to note is this escape sequence which changes the titlebar:

echo -n ]2;$*

or with a fixed string for illustration:

echo -n ]2;My new titlebar goes here

The rest of the stuff is just figuring out what string to put in the
titlebar (via $*), and how to hook the prompt change into the right
place so that it happens at every prompt.

-- 
Rob


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-09-05 Thread Steve Witt
On Sat, 6 Sep 1997, Lawrence wrote:

 Is it possible to do it in tcsh?
 

Yes, this is from the O'Reilly book Using csh  tcsh.  I use this at
work on SunOS 4.1.4 running tcsh.  There are two files involved, your
.cshrc (or .tchsrc) and another little file ~/.settitle.

= .cshrc ==

#-
#
# Set prompt display
#
#-

if (xterm =~ $TERM) then
source ~/.settitle
set prompt = %~ % 
else
alias setprompt 'set prompt = %~ % '
setprompt
alias cd 'cd \!*;setprompt'
alias pushd 'pushd \!*;setprompt'
alias popd  'popd \!*; setprompt'
endif


 ~/.settitle  ==

#
# .settitle - display path location in xterm title bar
#

alias settitle 'echo -n 2;$cwdttitle
alias cd 'cd \!*;settitle'
alias pushd 'pushd \!*;settitle'
alias popd 'popd \!*;settitle'



==
Steve Wittmailto:[EMAIL PROTECTED]
PairGain Technologies, Inc.  (714) 730-3245


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Re: Prompt in Bash

1997-08-23 Thread Dave Cinege
On Fri, 22 Aug 1997 12:32:35 -0300 (EST), Daniel Doro Ferrante wrote:



   Hi All !

   Does anybody know how do I change colors in a bash prompt. I can
do it in tcsh, but no succes with bash... (even after reading the man).


#b/w prompt
#PS1=\\h\\$ \\u [\\w] 

#Pretty color prompt. Comment it out if your terminal doesn't support ANSI co

#We must encase the ANSI codes in \[ and \] or else bash will have line lengt
#problems. \e is a pretty form of the raw escape sequence
PS1=\\[\\e[1;31m\\]\\h\\[\\e[0m\\]\\$ \\u [\\[\\e[1;34m\\]\\w\\[\\e[0m\\]] 

-
http://www.psychosis.com/emc/   Elite MicroComputers   908-541-4214
http://www.psychosis.com/linux-router/  Linux Router Project


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .


Prompt in Bash

1997-08-22 Thread Daniel Doro Ferrante


Hi All !

Does anybody know how do I change colors in a bash prompt. I can
do it in tcsh, but no succes with bash... (even after reading the man).

Thanks in advance.


Daniel.
__
Daniel Doro Ferranteemail: [EMAIL PROTECTED]
http://www.cecm.usp.br/~danieldf

CECM - Curso Experimental de Ciencias Moleculares - USP
   Experimental Course of Molecular Sciences - University of Sao Paulo


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word unsubscribe to
[EMAIL PROTECTED] . 
Trouble?  e-mail to [EMAIL PROTECTED] .