[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cat-ting binary files to the console



Andre Berger wrote:
> 
> On 2001-02-10 10:51 +0100, will trillich <will@serensoft.com> wrote:
> > On Thu, Feb 08, 2001 at 11:18:34AM -0600, Benjamin Pharr wrote:
> > > Every once in a while I slip up at cat a binary file to the console. (Or
> > > just forget to give mkisofs the -o flag.)  This causes the console to use
> > > WEIRD characters, just plain gibberish.  Is there any way to get rid of
> > > this without rebooting?  Thanks!
> >
> > this is a variation on the theme: put control-O into your PROMPT
> > string to reset your character set after every command:
> >
> >       # bash
> >       set PS1="^V^O whatever> "
> 
> Huh? Do you mean "export" instead of "set"? But the exported line
> displays verbatim here? (potato)

whoops. export is optional, i think; only the shell needs
to know the prompt settings. the "set" is for csh (maybe;
it's late...)

> ^V^O whatever>

that's how you'd enter it in an editor or at the prompt:

	PS1="^V^O whatever> "

those would be your keystrokes -- so that the variable
$PS1 would take on the value '^O whatever> '

the ^V just keeps the shell from interpreting ^O however it normally would,
which is probably something to do with flushing the output buffer (and
when it's waiting for you to enter a command, there's nothing to
flush). instead it reads it as a normal character to use as part of the
PS1 value.

when your terminal OUTPUTS a control-O, it resets its character
set to the default. (you can send a control-O from the terminal
to the computer, which may make it do some particular command;
we're after getting the ^O to be printed to reset the charset.)

and this should work just as well: ^O = chr(15) = "\017" so

	PS1='\017\u@\h:\w\$ '

ought to do the trick.

-- 
mailto:will@serensoft.com
http://www.dontUthink.com/



Reply to: