You are not logged in.
Pages: 1
For a script I want to turn off autowrap.
E.g. if the terminal is 5 characters wide
Usually:
$ echo $var
reall
ylong
line
$
What I want:
$ echo $var
reall
$
How do I do this? I don't want to check for the length of the line, because it contains escape codes (count towards length but take up zero space) and may also contain UTF (takes up one or two columns but is counted as 1 character or 3 in non-UTF locale).
I tried to use terminfo with things like tput am (automargin), tput smgrp 999 (set right margin with parameter), but they do nothing.
Last edited by Procyon (2010-07-21 19:27:51)
Offline
Why not counting the chars?
You can run a command before printing the prompt, so maybe you can use this to truncate the output. Not really portable. You would have somehow filter all the escape codes and figure out the widechars.
Edit: Sorry, if my suggestions is insane.
Last edited by karol (2010-07-21 17:38:11)
Offline
echo $var | cut -c -5
edit: oops, you wanted characters, not bytes (changed -b to -c)
Last edited by Trent (2010-07-21 18:06:06)
Offline
@ Trent
Try to echo this:
echo -e "\033[47m\033[1;37m White \033[0m\ 1;37m \ \033[40m\033[1;37m White \033[0m"
Last edited by karol (2010-07-21 18:14:15)
Offline
Echo it into the terminal, use xdotool to count 5 chars and delete the rest.
Offline
VT100/ANSI defines '^[7l' and '^[7h' as line wrap off and on, respectively. I couldn't get it to work in urxvt, though.
I'm not sure how does a non-wrapping output look like: does it overwrite the previous characters on the same line (i.e. it doesn't go into the next line, but doesn't disappear)?
Offline
@ Trent
Try to echo this:echo -e "\033[47m\033[1;37m White \033[0m\ 1;37m \ \033[40m\033[1;37m White \033[0m"
Exactly, it's quite tricky.
VT100/ANSI defines '^[7l' and '^[7h' as line wrap off and on, respectively. I couldn't get it to work in urxvt, though.
Thanks! I googled just line wrap off, and found the right code: ^[[?7l
Offline
Ah, I missed the "escape codes" constraint.
Offline
Pages: 1