Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k (22 Views)
Reply
Occasional Advisor
JLiYim
Posts: 10
Registered: ‎12-25-2002
Message 1 of 13 (22 Views)

Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Hi,

I have set the command prompt (PS1) to show the current working directory and am currently using vi to recall command history.

However, if my prompt is greater than 80 chars, it will be truncated to 80 chars when I recall the previous command using ESC-k. My screen width is 150 chars and it is really annoying and confusing when this happens.

Is there a way to prevent this from happening?

Thanks,
John
Please use plain text.
Outstanding Contributor
Pete Randall
Posts: 16,205
Registered: ‎11-03-1996
Message 2 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

John,

I just tried it with a 100 character (bogus) command and got all 100 characters back. I had to scroll to the right to see them, but they were there. I'm using an HPTerm on CDE with 11.11 (PA-RISC flavored), and "set -o vi" + "export HISTFILE=" to get command line editing.


Pete

Pete
Please use plain text.
Honored Contributor
Andreas Voss
Posts: 1,364
Registered: ‎10-14-1997
Message 3 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Hi,

try this command to set the current window size environment:

eval $(resize)

Regards
Please use plain text.
Honored Contributor
Sanjay Kumar Suri
Posts: 1,063
Registered: ‎12-09-2003
Message 4 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Have you tried using following to edit the command?

h : move cursor one character to left
l : move cursor one character to right

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Please use plain text.
Occasional Advisor
JLiYim
Posts: 10
Registered: ‎12-25-2002
Message 5 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

It's not the command that gets truncated. It is the command prompt ... You can test this by going to a directory path that is greater than 80 chars with your command prompt set to display the current directory (export PS1='$PWD >>').

eval $(resize) does not work.
Please use plain text.
Outstanding Contributor
Pete Randall
Posts: 16,205
Registered: ‎11-03-1996
Message 6 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Oh, I see. In that case, you've got me. I would find having a command prompt of varying width (let alone greater than 80 characters!) far more disconcerting!

Sorry I couldn't help.


Pete

Pete
Please use plain text.
Honored Contributor
Stephen Keane
Posts: 1,155
Registered: ‎11-24-2004
Message 7 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

This appears to be a limitation/feature of the command prompt PS1 rather than the pwd command. If you set PS1 to a long string, it only displays the right hand 80 characters.
Please use plain text.
Honored Contributor
Sanjay Kumar Suri
Posts: 1,063
Registered: ‎12-09-2003
Message 8 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Check this link (last 20 lines):

http://www.nersc.no/~knutal/unix_tips.html


sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Please use plain text.
Occasional Advisor
JLiYim
Posts: 10
Registered: ‎12-25-2002
Message 9 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

This does not happen on CYGWIN and I wonder whether other UNIX platforms (SUN/IBM/Linux) have the same issue.

Anybody who has worked on Oracle E-Business Suite knows that some directory paths can easily be more than 80 chars and this is one of the reason why I set the window's width to be 140 or more.

I do not think that is is an issue with PS1 as this does not happen when I use emacs as the command editor.
Please use plain text.
Occasional Advisor
JLiYim
Posts: 10
Registered: ‎12-25-2002
Message 10 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Correction ... it does happen when I use emacs but only when I use CTRL-L. If I just use CTRL-P and CTRL-N, the command prompt remain unchanged.
Please use plain text.
Honored Contributor
Geoff Wild
Posts: 7,168
Registered: ‎06-04-2001
Message 11 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

Expand window, type in:

resize

Then you should see it.

This is what I do fro .profile

HOST=`uname -n`
PS1="
\$LOGNAME@\$HOST [ \$PWD ]
# ";export PS1

That way, commands are on line below the path.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Please use plain text.
Occasional Advisor
JLiYim
Posts: 10
Registered: ‎12-25-2002
Message 12 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

If there is no way to prevent the truncate, how can I ensure that the prompt only display the last 80 characters?

Currently, PS1 is set as follows:
export PS1='['`whoami`'@'`uname -n`']$PWD>> '

John
Please use plain text.
Honored Contributor
Bill Hassell
Posts: 14,205
Registered: ‎05-29-2000
Message 13 of 13 (22 Views)

Re: Command Prompt get truncated to 80 chars whenever recall command using ESC-k

After a while, these really long $PWD prompts can be very annoying, even if they are on a separate line. Usually, you know the parent structure of where you are located and you only need the current directory and the next higher directory. This will accomplish that task and avoid the truncation:

export PS1='${PWD##${PWD%/*/*}/} $ '
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation