Turn Off Word Wrap in Leopard Terminal

As I said in the post prior to this, I have really been enjoying using Terminal for accessing MySQL databases. I found a problem with it though. If you have a table with a lot of columns, or a column with a lot of data in it, Terminal will wrap the results of your query making it almost completely unreadable (or a pain to read at best).

I found a work-around. Though it isn’t as good as it could be, it does work. It prevents the wrap, but, everything beyond the right-side of your terminal window is completely removed. It doesn’t give you a scroll bar to see beyond, it is literally gone. If you try to resize your window, you’ll just get blank space.

Why Terminal doesn’t have the ability to turn it on or off is a mystery to me. But, that said, this fix does have it’s place, and it is fairly easy to turn on and off. Here’s what you do:

Open this file: $YOURHOME/.bashrc and place the following in there and save it:

# Wordwrap off
echo -e "\e[?7l\c"

After it is saved, you can close Terminal and re-open it, or restart bash with this command:

. ~/.bashrc

To turn it off again, just remove or comment out the echo statement you added to .bashrc and restart bash again.

If you have any better suggestions for this, please let me know! I’d love to have a better solution.

This entry was posted in Mac OS X, MySQL. Bookmark the permalink.

One Response to Turn Off Word Wrap in Leopard Terminal

  1. Brad Parks says:

    thanks! nice tip! btw, did you know that you can display your output in vertical format from mysql too?


    mysql test>select * from users where id=1\G

    I found that tip, and some more good ones at: