ibara / oksh

Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
352 stars 38 forks source link

command wrapping too early #74

Open apprehensions opened 1 year ago

apprehensions commented 1 year ago

on a stock build of suckless's st, the command wrapping begins very early (this has been extremely annoying for me, and i wish i can fucking disable this), and i'm not sure why.

on a OpenBSD system, using the same terminal, this issue does not occur.

ibara commented 1 year ago

What OS are you on?

apprehensions commented 1 year ago

...Linux? ncurses 6.4-1 oksh 7.2-1

167rgc911 commented 1 year ago

oksh-7.2-r0 ncurses-6.3_p20221119-r0 on AlpineLinux and this issue does not occur i also use dwm and st (i am in monocle layout so my cmdline is wide)

what is the output of 'set' from the cmdline?

CHARSET=UTF-8
COLUMNS=194
DISPLAY=:0

mind the 'COLUMNS' env var

apprehensions commented 1 year ago

The issue might be that ksh is failing to update when to wrap. Try to have the window starting in a small position then extend the window, you will then see that it will wrap very early, according to the window's geometry when ksh first started.

Maybe that it gets the columns and height once but doesn't check again.

username-null101 commented 1 year ago

Found the fix, I had this problem too

By looking through the man page, under the PS1 section, the escape chars '\[' and '\]' are for turning off character count and turning back on respectively(default behavior), so depending on how long is your prompt you will want to put the '\[' at the beggining and the '\]' to certain point, like a range of chars that the shell will ignore, for example my PS1 is: PS1="\[\033[01;32m@\033[01;33m\W\033[01;36m--\033[01;35m$(ls -A | wc -l)\]\033[01;33m ; "

I turned off the char count from the beginning and turned it back on after the ls command and that solved my problem

If i had specified the range of my whole prompt, then when you type, it breaks to the next line but then when you delete what you typed, it will not go back to the previous line, so thats why you will have to test a proper range with your prompt.

Hope this helps. (Had to edit the comment because the escape chars were not showing).