Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Tom H
On Sat, Nov 11, 2017 at 1:34 PM, jdow  wrote:
> On 2017-11-11 04:26, Tom H wrote:
>>
>> So it should be:
>>
>> PS1="\[\e[0m\][\u@\h:\l \w]\$ "
>
> Maybe. I got silly and experimented.
>
> PS1="\[\e[1m\][\u@\h:\l \w]\$ "
> and
> PS1="\e[1m[\u@\h:\l \w]\$ "
> and
> PS1="\e[1m[\\u@\\h:\\l \\w]\$ "
>
> all produce the same thing, which leaves the issue even more confused
> than when we started.

That's unsurprising because they're all the same (you're setting all
your text to bold, including what you type).


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread jdow

On 2017-11-11 04:26, Tom H wrote:


So it should be:

PS1="\[\e[0m\][\u@\h:\l \w]\$ "


Maybe. I got silly and experimented.

PS1="\[\e[1m\][\u@\h:\l \w]\$ "
and
PS1="\e[1m[\u@\h:\l \w]\$ "
and
PS1="\e[1m[\\u@\\h:\\l \\w]\$ "

all produce the same thing, which leaves the issue even more confused than when 
we started.


{^_^}


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread jdow

On 2017-11-11 06:30, Nico Kadel-Garcia wrote:

On Sat, Nov 11, 2017 at 8:10 AM, Tom H  wrote:

[ Hundreds of lines of fine-tuning prompt manipulation code and theory
snipped, especially involving quote handling ]

And *this* is why I ignore it all and just use "stty sane" when my
console gets confused.


Back with Hurricane, I think it was, I simply built an alias for that stty 
command and called it "clr". I "think" the \e[0m cured the screwed up text. At 
the very least I've not had it happen to me in a VERY long time.


{^_^}


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread jdow

On 2017-11-11 03:28, Tom H wrote:

On Fri, Nov 10, 2017 at 10:15 PM, Steven Haigh  wrote:


For what its worth, I've been using this for years:
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]
\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID}
== 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\
[\033[01;34m\] \w \$\[\033[00m\] "


If you use single-quotes for PS1, you can use unescaped double-quotes
and dollar signs within it. It makes it more legible:

PS1='\[\033[01;37m\]$? $(if [[ $? == 0 ]]; then echo
"\[\033[01;32m\]\342\234\223"; else echo
"\[\033[01;31m\]\342\234\227"; fi) $(if [[ ${EUID} == 0 ]]; then echo
"\[\033[01;31m\]\h"; else echo "\[\033[01;32m\]\u@\h";
fi)\[\033[01;34m\] \w \$\[\033[00m\] '

You might be better off using "printf" (it's a bash builtin) because
"echo" might not interpret escapes depending on the bash or shell
options that are set.


It works for him, apparently. So that's good. Now, in pedantic mode each of the 
\033 strings can be changed to \e for easier readability.


{^_-}


Re: [EXTERNAL] Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread ONeal, Miles
Or just “reset”.

-Miles

On Nov 11, 2017, at 08:33, Steven Haigh 
> wrote:

On Sunday, 12 November 2017 1:30:45 AM AEDT Nico Kadel-Garcia wrote:
On Sat, Nov 11, 2017 at 8:10 AM, Tom H 
> wrote:

[ Hundreds of lines of fine-tuning prompt manipulation code and theory
snipped, especially involving quote handling ]

And *this* is why I ignore it all and just use "stty sane" when my
console gets confused.

heh - personally, I just type: reset

--
Steven Haigh

 net...@crc.id.au    http://www.crc.id.au
 +61 (3) 9001 6090 0412 935 897


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Tom H
On Sat, Nov 11, 2017 at 9:30 AM, Nico Kadel-Garcia  wrote:
> On Sat, Nov 11, 2017 at 8:10 AM, Tom H  wrote:


> [ Hundreds of lines of fine-tuning prompt manipulation code and theory
> snipped, especially involving quote handling ]

Hundreds?!

Hopefully someone find them useful!


> And *this* is why I ignore it all and just use "stty sane" when my
> console gets confused.

"ssty sane"
"reset"
"printf \033c"

Prefixed with a linefeed ("ctrl-j") so as to ensure that the actual
command doesn't start with any of the previous garbage.


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Alan Bartlett
On 11 November 2017 at 14:33, Steven Haigh  wrote:
> On Sunday, 12 November 2017 1:30:45 AM AEDT Nico Kadel-Garcia wrote:
>> On Sat, Nov 11, 2017 at 8:10 AM, Tom H  wrote:
>>
>> [ Hundreds of lines of fine-tuning prompt manipulation code and theory
>> snipped, especially involving quote handling ]
>>
>> And *this* is why I ignore it all and just use "stty sane" when my
>> console gets confused.
>
> heh - personally, I just type: reset
>
> --
> Steven Haigh

Coming from Unix System III, of many, many, years ago, my "magic
incantation" is just that prefixed and suffixed by .

I.e.: reset

Alan.


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Steven Haigh
On Sunday, 12 November 2017 1:30:45 AM AEDT Nico Kadel-Garcia wrote:
> On Sat, Nov 11, 2017 at 8:10 AM, Tom H  wrote:
> 
> [ Hundreds of lines of fine-tuning prompt manipulation code and theory
> snipped, especially involving quote handling ]
> 
> And *this* is why I ignore it all and just use "stty sane" when my
> console gets confused.

heh - personally, I just type: reset

-- 
Steven Haigh

 net...@crc.id.au    http://www.crc.id.au
 +61 (3) 9001 6090 0412 935 897

signature.asc
Description: This is a digitally signed message part.


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Nico Kadel-Garcia
On Sat, Nov 11, 2017 at 8:10 AM, Tom H  wrote:

[ Hundreds of lines of fine-tuning prompt manipulation code and theory
snipped, especially involving quote handling ]

And *this* is why I ignore it all and just use "stty sane" when my
console gets confused.


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Tom H
On Fri, Nov 10, 2017 at 10:15 PM, Steven Haigh  wrote:
>
> For what its worth, I've been using this for years:
> PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]
> \342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID}
> == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\
> [\033[01;34m\] \w \$\[\033[00m\] "

If you use single-quotes for PS1, you can use unescaped double-quotes
and dollar signs within it. It makes it more legible:

PS1='\[\033[01;37m\]$? $(if [[ $? == 0 ]]; then echo
"\[\033[01;32m\]\342\234\223"; else echo
"\[\033[01;31m\]\342\234\227"; fi) $(if [[ ${EUID} == 0 ]]; then echo
"\[\033[01;31m\]\h"; else echo "\[\033[01;32m\]\u@\h";
fi)\[\033[01;34m\] \w \$\[\033[00m\] '

You might be better off using "printf" (it's a bash builtin) because
"echo" might not interpret escapes depending on the bash or shell
options that are set.


Re: Tip: when your terminal gets all screwed up

2017-11-11 Thread Tom H
On Fri, Nov 10, 2017 at 7:21 PM, jdow  wrote:
> On 2017-11-10 15:14, ToddAndMargo wrote:
>>
>> Ever cat a binary file by accident and your
>> terminal gets all screwed up.
>>
>> I had a developer on the Perl 6 chat line give me
>> a tip on how to unscrew your terminal and set it
>> back to normal. (He way helping me do a binary
>> read from the keyboard.)
>>
>> stty sane^j
>>
>> Note: it is , not "enter".
>
> Make "\033]0;" the first bit of your prompt. Never
> worry about it again.
>
> ESC-0 sets the terminal to have no attribute bits
> set. So it clears funny display. I've had that as
> a standard part of my prompts for decades, even
> back in the CP/M days.

It's "\033[0m" that resets attributes not "\033]0;".

"\033]0;" sets the xterm window title and the xterm icon name to the
text that follows (up until "\007").


Re: Tip: when your terminal gets all screwed up

2017-11-10 Thread Steven Haigh
On Saturday, 11 November 2017 1:48:23 PM AEDT jdow wrote:
> On 2017-11-10 16:38, ToddAndMargo wrote:
> > On 11/10/2017 04:21 PM, jdow wrote:
> >> On 2017-11-10 15:14, ToddAndMargo wrote:
> >>> Dear List,
> >>> 
> >>> Ever cat a binary file by accident and your
> >>> terminal gets all screwed up.
> >>> 
> >>> I had a developer on the Perl 6 chat line give me
> >>> a tip on how to unscrew your terminal and set it
> >>> back to normal.  (He way helping me do a binary
> >>> read from the keyboard.)
> >>> 
> >>> stty sane^j
> >>> 
> >>> Note: it is , not "enter".
> >>> 
> >>> -T
> >> 
> >> Make "\033]0;" the first bit of your prompt. Never worry about it again.
> >> 
> >> ESC-0 sets the terminal to have no attribute bits set. So it clears funny
> >> display. I've had that as a standard part of my prompts for decades, even
> >> back in the CP/M days.
> >> {^_^}   Joanne
> > 
> > Sweet!
> 
> Here is what I have in my .bash_profile file:
> 
> 
> if [ "$PS1" ]; then
># extra [ in front of \u unconfuses confused Linux VT parser
>PS1="\e[0 [[\\u@\\h:\\l \\w]\\$ "
> fi

For what its worth, I've been using this for years:
PS1="\[\033[01;37m\]\$? \$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]
\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi) $(if [[ ${EUID} 
== 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\
[\033[01;34m\] \w \$\[\033[00m\] "

Stick it all on one line. Add the \e[0 in front, and that'd be pretty cool :)

-- 
Steven Haigh

 net...@crc.id.au    http://www.crc.id.au
 +61 (3) 9001 6090 0412 935 897

signature.asc
Description: This is a digitally signed message part.


Re: Tip: when your terminal gets all screwed up

2017-11-10 Thread ToddAndMargo

On 11/10/2017 06:48 PM, jdow wrote:

On 2017-11-10 16:38, ToddAndMargo wrote:

On 11/10/2017 04:21 PM, jdow wrote:

On 2017-11-10 15:14, ToddAndMargo wrote:

Dear List,

Ever cat a binary file by accident and your
terminal gets all screwed up.

I had a developer on the Perl 6 chat line give me
a tip on how to unscrew your terminal and set it
back to normal.  (He way helping me do a binary
read from the keyboard.)

stty sane^j

Note: it is , not "enter".

-T


Make "\033]0;" the first bit of your prompt. Never worry about it again.

ESC-0 sets the terminal to have no attribute bits set. So it clears 
funny display. I've had that as a standard part of my prompts for 
decades, even back in the CP/M days.

{^_^}   Joanne


Sweet!

Here is what I have in my .bash_profile file:


if [ "$PS1" ]; then
   # extra [ in front of \u unconfuses confused Linux VT parser
   PS1="\e[0 [[\\u@\\h:\\l \\w]\\$ "
fi

{^_^}



Thank you!

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: Tip: when your terminal gets all screwed up

2017-11-10 Thread jdow

On 2017-11-10 16:38, ToddAndMargo wrote:

On 11/10/2017 04:21 PM, jdow wrote:

On 2017-11-10 15:14, ToddAndMargo wrote:

Dear List,

Ever cat a binary file by accident and your
terminal gets all screwed up.

I had a developer on the Perl 6 chat line give me
a tip on how to unscrew your terminal and set it
back to normal.  (He way helping me do a binary
read from the keyboard.)

stty sane^j

Note: it is , not "enter".

-T


Make "\033]0;" the first bit of your prompt. Never worry about it again.

ESC-0 sets the terminal to have no attribute bits set. So it clears funny 
display. I've had that as a standard part of my prompts for decades, even back 
in the CP/M days.

{^_^}   Joanne


Sweet!

Here is what I have in my .bash_profile file:


if [ "$PS1" ]; then
  # extra [ in front of \u unconfuses confused Linux VT parser
  PS1="\e[0 [[\\u@\\h:\\l \\w]\\$ "
fi

{^_^}


Re: Tip: when your terminal gets all screwed up

2017-11-10 Thread jdow
And that has an oops in it. Don't include the ";". The proper escape sequence 
would be "esc[0". My bad. Been too long since I did more than copy stuff.


{^_^}

On 2017-11-10 16:28, Carl Friedberg wrote:

That is cool.

I've had (in the VT220/320) some pretty wild prompts.

There was a thunderbolt, and for the holidays, someone
crafted Santa, a sleigh, and reindeer. People must have
had more time back then, or else no one who was in
charge had any idea what they were doing. Or both.

Carl Friedberg
(212) 798-0718
www.esb.com
The Elias Book of Baseball Records
2017 Edition

-Original Message-
From: owner-scientific-linux-us...@listserv.fnal.gov 
[mailto:owner-scientific-linux-us...@listserv.fnal.gov] On Behalf Of jdow
Sent: Friday, November 10, 2017 7:22 PM
To: scientific-linux-users@fnal.gov
Subject: Re: Tip: when your terminal gets all screwed up

On 2017-11-10 15:14, ToddAndMargo wrote:

Dear List,

Ever cat a binary file by accident and your
terminal gets all screwed up.

I had a developer on the Perl 6 chat line give me
a tip on how to unscrew your terminal and set it
back to normal.  (He way helping me do a binary
read from the keyboard.)

stty sane^j

Note: it is , not "enter".

-T


Make "\033]0;" the first bit of your prompt. Never worry about it again.

ESC-0 sets the terminal to have no attribute bits set. So it clears funny
display. I've had that as a standard part of my prompts for decades, even back
in the CP/M days.
{^_^}   Joanne





RE: Tip: when your terminal gets all screwed up

2017-11-10 Thread Carl Friedberg
That is cool.

I've had (in the VT220/320) some pretty wild prompts.

There was a thunderbolt, and for the holidays, someone
crafted Santa, a sleigh, and reindeer. People must have
had more time back then, or else no one who was in
charge had any idea what they were doing. Or both.

Carl Friedberg
(212) 798-0718
www.esb.com
The Elias Book of Baseball Records
2017 Edition

-Original Message-
From: owner-scientific-linux-us...@listserv.fnal.gov 
[mailto:owner-scientific-linux-us...@listserv.fnal.gov] On Behalf Of jdow
Sent: Friday, November 10, 2017 7:22 PM
To: scientific-linux-users@fnal.gov
Subject: Re: Tip: when your terminal gets all screwed up

On 2017-11-10 15:14, ToddAndMargo wrote:
> Dear List,
> 
> Ever cat a binary file by accident and your
> terminal gets all screwed up.
> 
> I had a developer on the Perl 6 chat line give me
> a tip on how to unscrew your terminal and set it
> back to normal.  (He way helping me do a binary
> read from the keyboard.)
> 
> stty sane^j
> 
> Note: it is , not "enter".
> 
> -T

Make "\033]0;" the first bit of your prompt. Never worry about it again.

ESC-0 sets the terminal to have no attribute bits set. So it clears funny 
display. I've had that as a standard part of my prompts for decades, even back 
in the CP/M days.
{^_^}   Joanne


Re: Tip: when your terminal gets all screwed up

2017-11-10 Thread jdow

On 2017-11-10 15:14, ToddAndMargo wrote:

Dear List,

Ever cat a binary file by accident and your
terminal gets all screwed up.

I had a developer on the Perl 6 chat line give me
a tip on how to unscrew your terminal and set it
back to normal.  (He way helping me do a binary
read from the keyboard.)

stty sane^j

Note: it is , not "enter".

-T


Make "\033]0;" the first bit of your prompt. Never worry about it again.

ESC-0 sets the terminal to have no attribute bits set. So it clears funny 
display. I've had that as a standard part of my prompts for decades, even back 
in the CP/M days.

{^_^}   Joanne