Benches macOS

7

Text in terminal window not wrapping

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I checked the prefs for the terminal window and wrapping is on however... nothing wraps. It's been a few years since I've gotten my hands dirty with a *NIX command line but I never remember this behavior... If I type a command like...

ioreg -l | grep IOBatteryInfo

... anything that doesn't fit on the terminal just falls off the screen instead of wrapping. If I expand the size of the terminal, type the command and then resize it so that it's small everything wraps, it's just when actually running a command that it doesn't. Is there a way to change this behavior with the OSX terminal?

Cheers, Joe

7 replies

Sign in or join Beachball Help to reply.

  1. 0

    Boyd

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    It probably depends on the *nix utility producing the output - whether or not it is using the terminal characteristics or not. My work-around is to pipe the output to fold -s, like

    ioreg|grep AppleCPUVoltage|fold -s

    Boyd

  2. 0

    Gary Kerbaugh

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi Joe,

    I didn't know about the "fold" utility, thank you very much Boyd! However, you should test suggestions if possible. Unfortunately "fold" doesn't help, it's "ioreg" that's clipping the output. It seems to be set to clip the output at 80 characters by default. On the other hand, you know the old addage: RTFM. "Ioreg" has a -w option and if you give it an argument of 0, it will output the entire line
    and wrap it.

    --

    Gary

    ~~~~

    Everyone is entitled to my opinion.

  3. 0

    Joseph Ciarcia

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi Gary,

    Unfortunately the -w argument clips the text, it doesn't actually wrap it (although that would be nice... the choice of w for the argument is kind of misleading). fold seems to do the trick though (thanks Boyd).

    Cheers, Joe

  4. 0

    Gary Kerbaugh

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi Joe,

    > Unfortunately the -w argument clips the text, it doesn't

    actually wrap it

    DId you provide a numeric argument to the "-w" option as specified in the man page? On mine, using Apple's Terminal, if I execute "ioreg" with no argument, it prints 79 characters of output for each line and a dollar sign, '$', in the 80
    th column to indicate that truncation has occurred. (My terminal window is 80 characters wide) If I execute "ioreg -w 82", it produces 82 characters of output for each line. The 81
    st character of is wrapped to the first character of the next line and a dollar sign follows that to indicate truncation. The output actually looks kind of cool; every other line consists of one character and a '$' character. If I execute "ioreg -w 0" I see the entire output for each line, each wrapped across two lines in the Terminal, and no dollar signs.

    If I enlarge my Terminal window to a width of 81 characters, executing "ioreg -w 83" again produces one character of output and a '$' character on every other line. Executing "ioreg -w 0" again produces the entire output correctly wrapped after the 81
    st character.

    In all tests above, ioreg was both aware of the width of my Terminal window and wrapped the text exactly as I specified. The above tests produced the same results on my 10.4.2 system and a 10.3.8 system. Were your tests performed on the 10.4 system listed in your profile?

    Were your failing tests performed in Apple's Terminal? The shell I used for these tests was zsh, my default shell. Were your failing tests performed in bash? If bash is somehow causing your ioreg to fail to function properly, then that could be the best argument yet for switching to zsh! To quote Bill Scott in
    Why is my Default Shell 'tcsh'??:

    Behold, for zsh is the only true shell. All others are false prophets.

    Preach it, brother! and then
    convert to it.

    EDIT: Rats! On my system, "ioreg" functions correctly when used in bash, producing the same results I described above. Please forgive my disappointment but this could have provided significant fuel for our "zsh evangelism". Were you using Apple's Terminal? I'm running out of theories for why ioreg, which seems to have excellent terminal awareness and wrapping capability, is failing so miserably on your system!

    --

    Gary

    ~~~~

    <SlayR> i just bought MS Office 2000 for only $20!!!

    <Knghtbrd> you got ripped off ;>

    <SlayR> i know 😉

  5. 0

    Nils C. Anderson

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    on my system, the '-w 0' is wrapping the line. using xterm-color

    for my terminal setting in the Terminal.app.

    ioreg -l -w 0 | grep IOBatteryInfo

    Thanks,

    Gary

  6. 0

    Joseph Ciarcia

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I'm running out of theories for why ioreg,

    which seems to have excellent terminal awareness

    and wrapping capability, is failing so miserably

    on your system!

    Uhhh... I have a theory... the driver needs to start drinking coffee or get less stupid or... something. LOL Yeah it works. Now pardon me while I go extract this bullet from my foot. D'OH!

    Thanks for being patient with me.

    Cheers, Joe

  7. 0

    Gary Kerbaugh

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi Joe,

    That's hilarious and I know what you mean. Sometimes it's all I can do to get my foot out of my mouth before I shoot myself in it! 🙂 The main thing is that it works, yeah! I was distressed because "ioreg" appears to be one of Apple's better utilities in terms of terminal awareness. One wants the better gems in the jewelry to shine most brightly.

    The most important lesson to be taken from this is the value of the man pages. At best they are spartan and at worst, cryptic in their descriptions of what's going on. However, they are usually pretty good at specifying syntax. It takes a while to get comfortable with the notation of descriptions of syntax but the wider one's repertoire of UNIX utilities, the more dependent one becomes on the man pages for the intricacies of syntax. A foot in the mouth doesn't leave much room in the head.

    --

    Gary

    ~~~~

    Adding features does not necessarily increase

    functionality -- it just makes the manuals thicker.