Operating System - HP-UX
1827769 Members
2828 Online
109969 Solutions
New Discussion

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

 
JLiYim
Occasional Advisor

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
12 REPLIES 12
Pete Randall
Outstanding Contributor

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
Andreas Voss
Honored Contributor

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
Sanjay Kumar Suri
Honored Contributor

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.
JLiYim
Occasional Advisor

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.
Pete Randall
Outstanding Contributor

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
Stephen Keane
Honored Contributor

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.
Sanjay Kumar Suri
Honored Contributor

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.
JLiYim
Occasional Advisor

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.
JLiYim
Occasional Advisor

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.
Geoff Wild
Honored Contributor

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.
JLiYim
Occasional Advisor

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
Bill Hassell
Honored Contributor

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%/*/*}/} $ '


Bill Hassell, sysadmin