Turn off terminal word wrap in Leopard?

One of my favorite features in tiger's terminal was the ability to turn OFF the word wrap. It was under Terminal->Window Settings...->Buffer->Wrap lines that are too long. I could uncheck that box and it would be helpful in viewing logfiles scrolling by quickly (using tail -f).

I think I'm insane because I cannot find this most basic feature in Leopard's terminal. I've experimented with some turning off some of the default settings like, Autowrap, Backwrap, and RewrapOnResize and changing these seems to have no effect. Can anyone tell me if this feature is gone forever?

I really would like to know how to turn off word wrap in leopard terminal.

Mac OS X (10.5.4)

Posted on Aug 26, 2008 2:19 PM

Reply
6 replies

Aug 26, 2008 5:02 PM in response to Christopher Goodman

Add the following to your $HOME/.bashrc file:

#
# e (escape)
# [ (open square bracket)
# ? (question mark)
# 7 (seven)
# l (el - lowercase L)
# c (tells echo to suppress the newline; this is optional)
#
echo -e "e[?7lc"

If you want to turn line wrapping back on, use

echo -e "e[?7hc"

These are the ANSI Escape sequences that tell the terminal how to handle line wrapping.

I got these escape sequences from the Digital Equipment Corporation (DEC),
merged with Compaq, aquired by HP,
"man 5 dtterm" page.

<http://h30097.www3.hp.com/docs/base doc/DOCUMENTATION/V51_HTML/MAN/MAN5/0200___.HTM>

I find this man page one of the best sources ANSI escape sequences.

Aug 28, 2008 4:45 AM in response to BobHarris

Hi Bob,

I didn't know that auto-wrap (or auto-margin) can be turned on/off by sending the escape sequences; thank you for the info.

In tcsh, echo can handle escape sequences if the option "echo_style" is set to "both" (or "sysv"). See man tcsh and search for "echo_style".

In addition, it would be better to echo the escape sequence only if the shell is an interactive shell.

#
# aliases for turn on/off the auto-wrap
#
alias wrap_off 'set echo_style=both; echo -n "e[?7l"'
alias wrap_on 'set echo_style=both; echo -n "e[?7h"'
#
# if you want auto-wrap to be turned off automatically
# at the start of an interactive tcsh session:
#
if ($?prompt) then # if interactive shell
wrap_off
endif

Aug 28, 2008 5:49 AM in response to Jun T.

I didn't know that auto-wrap (or auto-margin) can be turned on/off by sending the escape sequences; thank you for the info.

I didn't know off the top of my head either, but I know that the escape sequences that character cell terminals accepted was huge. So I went searching in the dtterm man page (section 5) from the Tru64 UNIX documentation, and found it.

What I do use a lot is my own escape sequences for adding color to my scripts, and especially my command prompts. I have a very large section of my .bashrc that is devoted to choosing my prompt colors depending on which system I using and if I'm in any special modes (such as root, or working in a development sandbox, etc...).

I use the following script to choose my colors and the associated escape sequence:

#!/bin/sh
#-----------------------------------------------------------------------------
# colors.esc - display the terminal colors and the escape sequences that
# generate them. "Blink" is _NOT_ shown, as it is a very
# annoying effect, and should be avoided at all costs in normal
# daily uses.
#
# Usage: colors.esc
#-----------------------------------------------------------------------------
# Bob Harris
#-----------------------------------------------------------------------------
E=$(printf ' ') # escape <E>
R="${E}[0m" # reset <E>[0m
typeset dsp_str=""
typeset dsp_txt
typeset fg_text
typeset bg_text
if [[ $# != 0 ]]; then
dsp_str=$(printf "%12.12s" "$*")
fi
color=(Black Red Green Yellow Blue Magenta Cyan White)
for bg in "" 0 1 2 3 4 5 6 7 # for each background color
do
b=$bg && [[ X$b != X ]] && b="4$b;" # deal with no background color ""
echo " ------------ ----bold---- -underline-- --reverse---"
for fg in 0 1 2 3 4 5 6 7 # for each foreground color
do
f="3$fg" # setup foreground color
line=""
for a in "" 1 4 7 # for each attribute
do
[[ X$a != X ]] && a=";$a" # deal with no attribute ""
if [[ -z "$dsp_str" ]]; then
dsp_txt=$(printf "%12s" "<E>[${b}${f}${a}m") # build esc text
else
dsp_txt="$dsp_str" # use supplied text
fi
line="${line}${E}[${b}${f}${a}m${dsp_txt}${R} " # build entry
done
fg_text=$(printf "%-7s" ${color[$fg]}) # translate foreground color
bg_text=$(printf "%-9s" "Bg${color[$bg]}") # translate background color
[[ X$b = X ]] && bg_text=$(printf "%-9s" " ") # no bckgnd color
line="$bg_text $fg_text $line" # build final display line
echo "${line% }" # display the colorized line
done
done
echo " ------------ ----bold---- -underline-- --reverse---"
bg_text=$(printf "%-9s" " ")
fg_text=$(printf "%-7s" "Reset")
dsp_txt=$(printf "%12s" "<E>[0m")
line="$bg_text $fg_text $dsp_txt" # build final display line
echo "${line% }"

Sep 16, 2008 6:51 AM in response to BobHarris

BobHarris wrote:
Add the following to your $HOME/.bashrc file:

#
# e (escape)
# [ (open square bracket)
# ? (question mark)
# 7 (seven)
# l (el - lowercase L)
# c (tells echo to suppress the newline; this is optional)
#
echo -e "e[?7lc"

If you want to turn line wrapping back on, use

echo -e "e[?7hc"



I did this, and it did work, which is great. However, instead of allowing you to sroll to the right, it just chops off all of the overflow. Is there a way that we can make terminal be able to scroll to the right instead of losing data?

I use MySQL through the command line, and some tables are quite wide. If it wraps, it looks horrible and is almost impossible to read. If I turn the wrapping off, then I lose a bunch of data.

Any suggestions anyone?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Turn off terminal word wrap in Leopard?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.