views:

1436

answers:

5

Okay, I'm sure this is simple but it is driving me nuts. I recently went to work on a program where I've had to step back in time a bit and use Redhat 9. When I'm typing on the command line from a standard xterm running Korn shell, when I reach the end of the line the screen slides to the right (cutting off the left side of my command) instead of wrapping the text around to a new line. This makes things difficult for me because I can't easily copy and paste from the previous command straight from the command line. I have to look at the history and paste the command from there. In case you're wondering, I do a lot of command-line awk scripts that cause the line to get quite long.

Is there a way to force the command line to wrap instead of shifting visibility to the right side of the command I'm typing? I've poured through man page options with no luck. I'm running XFree86 4.2.99.903(174) and KSH 5.2.14. Thanks.

+1  A: 

If possible, try to break the command down to multiple lines by adding \ ie:

$ mycommand -a foo \
  -f bar \
  -c dif
Achille
A: 

I don't know of a way of forcing the shell to wrap, but I would ask why you'd be writing lines that long. With awk scripts, I simply wrap the script in single quotes, and then break the lines where I want. It only gets tricky if you need single quotes in the script -- and diabolical if you need both single and double quotes. Actually, the rule is simple enough: use single quotes to wrap the whole script, and when you want a single quote in the script, write '\''. The first quote terminates the previous single-quoted string; the backslash-single quote yields a single quote; and the last single quote starts a new single quoted string. It really gets hairy if you need to escape those characters for an eval or something similar.

The other question is - why not launch into an editor. Since I'm a die-hard vim nutcase (ok - I've been using vi for over 20 years, so it is easier for me than the alternatives), I have Korn shell set to vi mode (set -o vi), and can do escape-v to launch the editor on whatever I've typed.

Jonathan Leffler
+3  A: 

Did you do man ksh?

You want to do a set -o multiline.

Excerpt from man ksh:

multiline:

The built-in editors will use multiple lines on the screen for lines that are longer than the width of the screen. This may not work for all terminals.

ΤΖΩΤΖΙΟΥ
Works for putty - and it had been driving me mental!
Anonymouslemming
A: 

This is kind of a pragmatic answer, but when that's an issue for me I usually do something like:

strings ~/.history | grep COMMAND

or

strings ~/.history | tail

(The history file has a little bit of binary data in it, hence 'strings')

jj33
A: 

eval $(resize) should do it.

Boune