Re: escape codes in ksh "\033]0;\$PWD\007\$PWD> "
Robert Body wrote: > I have not been able to figure out how to send escape codes to ksh > > I saw a syntax for ksh on > http://www.steveshilling.pwp.blueyonder.co.uk/scripts/xtermtitle.txt > - > PS1='^[]0;[EMAIL PROTECTED]: ${PWD}^Gksh$ ' I don't think ksh supports pasrsing of escape characters in environment variables - but you'd have to ask Igor to be sure. That means you have to insert the literal escape character. When you do this most shells will display it as "^[" even though it's actually just one character, which is the source of your confusion. For example, at a bash prompt: PS1='^[[33mYellow! $ ' ksh (where again ^[ is not "^" and "[" but control-v then escape) But what you probably want to do is set this in the .profile or whatever. To do that you'll have to do whatever incantation your chosen text editor uses for inserting raw characters. I think vim uses ^V too - but I don't know because I don't use vim. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: escape codes in ksh "\033]0;\$PWD\007\$PWD> "
On Tue, 22 Nov 2005, Robert Body wrote: > I have not been able to figure out how to send escape codes to ksh KSH does not understand escape codes. You have to embed literal special characters into $PS1. > I saw a syntax for ksh on > http://www.steveshilling.pwp.blueyonder.co.uk/scripts/xtermtitle.txt > - > PS1='^[]0;[EMAIL PROTECTED]: ${PWD}^Gksh$ ' > - > where ^[ is used instead of \033 and ^G instead of \007 > but I tried 3 systems with ksh, no go, it doesn't understand escape > characters, not with \032, not with \[\e and not with ^[ to signfy beginning > of escape code... ksh just repeats them exactly like regular characters In bash, you can type in the following character sequence (sans the spaces): P S 1 = ' Ctrl-V Esc ] 0 ; $ { U S E R } @ $ { H O S T } : Space $ { P W D } Ctrl-V Ctrl-G k s h $ Space ' To get the above prompt. Then start ksh. > in bash it's easy > > PS1='\[\e]0;$PWD\a\]$PWD> '# (in title) HOST-$PWD ... $PATH> > > > I came up with the following... needs perl, needs xterm > but works in ksh, and bash too > > PS1=$(perl -e 'printf "\033]0;\$PWD\007\$PWD> "') > Sure, that works too. You can use awk or sed instead of perl (which have the advantage of being part of the default installation). > but i just don't know how (and someone must know how) people get the > escape codes into ksh that it works from command prompt or script with a > one line solution (and without secondary help from something like c or > perl code) Both vi and emacs allow you to enter special characters literally. Edit your .profile (or /etc/profile), and you're all set. The ksh-related section of the default /etc/profile has a bug and doesn't work. > Oh, the purpose of this escape sequence is to synchronize the title with > PS1 to be the current directory on an xterm (but the question is about > escape codes, not xterm ;-) ) Again, ksh does not understand escape codes. Neither does ash. Use literal characters. Igor Pechtchanski Volunteer PDKSH maintainer for Cygwin -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_[EMAIL PROTECTED] ZZZzz /,`.-'`'-. ;-;;,_[EMAIL PROTECTED] |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! If there's any real truth it's that the entire multidimensional infinity of the Universe is almost certainly being run by a bunch of maniacs. /DA -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Re: escape codes in ksh "\033]0;\$PWD\007\$PWD> "
I have not been able to figure out how to send escape codes to ksh I saw a syntax for ksh on http://www.steveshilling.pwp.blueyonder.co.uk/scripts/xtermtitle.txt - PS1='^[]0;[EMAIL PROTECTED]: ${PWD}^Gksh$ ' - where ^[ is used instead of \033 and ^G instead of \007 but I tried 3 systems with ksh, no go, it doesn't understand escape characters, not with \032, not with \[\e and not with ^[ to signfy beginning of escape code... ksh just repeats them exactly like regular characters in bash it's easy PS1='\[\e]0;$PWD\a\]$PWD> '# (in title) HOST-$PWD ... $PATH> I came up with the following... needs perl, needs xterm but works in ksh, and bash too PS1=$(perl -e 'printf "\033]0;\$PWD\007\$PWD> "') but i just don't know how (and someone must know how) people get the escape codes into ksh that it works from command prompt or script with a one line solution (and without secondary help from something like c or perl code) Oh, the purpose of this escape sequence is to synchronize the title with PS1 to be the current directory on an xterm (but the question is about escape codes, not xterm ;-) ) -Robert -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/