On 2017-11-10 19:15, Steven Haigh wrote:
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 <ctr><J>, 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 :)
So I went through some documentation. Now I am back up to speed for ANSI escape
sequences and the theoretical interaction of PROMPT_COMMAND and PS1.
PROMPT_COMMAND is run then PS1 is displayed. PROMPT_COMMAND already has the \e0m
in it. \e is bash for escape. There is a list of the things in man bash, of course.
"\e[0m[\\u@\\h: \\w]\\$ " is what I should have used. The m makes it do its
thing. Gawd it's a long time since I did something with VT commands directly. It
all leaked out! Don't get old.
{^_^}