Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A guide to help set up Terminal Apps
Note that this guide assumes you're using the bash shell. This guide will address a few Terminal setup questions:
  • How do I get the backspace and forward delete keys to work correctly?
  • How do I get UTF–8 input to work correctly?
  • How do I get UTF–8 input to, you know, work correctly?
  • How do I get UTF–8 input to work correctly in irssi running under screen over a ssh connection?
  • How do I modify the default ANSI colors?
Read on for the answers to those questions...

How do I get the backspace and forward delete keys to work correctly?
  • In the Keyboard section of the Terminal Inspector (Command-I in Terminal):
    • Turn on the Delete key sends backspace option.
    • Map the forward delete key to the following string: \033[3~
  • Add the following line to your .profile: stty erase ^H. Since ^H is a non–printable control character, the easiest way to do this is to execute the following command: echo -e "stty erase ^H" >> ~/.profile. Type the ^H by pressing Control–V and Control–H.
  • Add the following line to your .inputrc: "\e[3~": delete-char
  • Apply changes by doing a source ~/.profile and a source ~/.inputrc.
How do I get UTF–8 input to work correctly?
  • In the Terminal Inspector:
    • In the Emulation section, turn off the Escape non-ASCII characters option.
    • In the Display section, choose Unicode (UTF-8) as the Character Set Encoding.
  • Add the following line to your .profile: export LC_CTYPE=en_US.UTF-8
  • Add the following lines to your .inputrc:
    set meta-flag on
    set input-meta on
    set output-meta on
    set convert-meta off
  • Apply changes by doing a source ~/.profile and a source ~/.inputrc.
How do I get UTF–8 input to, you know, work correctly?

There's an odd bug in the version of bash included with Mac OS X 10.4 that manifests itself as the LC_CTYPE enviroment variable not being set properly by export directives in .profile files. The workaround involves using the little–known environment.plist file. Thanks to Allan Odgaard for the tip!
  • Add a LC_CTYPE key with the value en_US.UTF-8 to the root dictionary of the ~/.MacOSX/environment.plist file. Assuming that you don't have that file, the easiest way to do this is to execute the following command:
    echo "{ LC_CTYPE = \"en_US.UTF-8\"; }" > ~/.MacOSX/environment.plist
    You could also use Property List Editor.app.
  • Apply changes by logging out and back in.
How do I get UTF–8 input to work correctly in irssi running under screen over a ssh connection?

You're a tricky one, aren't you?
  • Copy the relevant parts of your .profile and .inputrc to the remote host.
  • Start screen with the -U option.
  • In irssi 0.8.9 and older, set term_type to utf-8. In newer versions, set term_charset to utf-8.
After detaching, remember to reattach also using the -U option. This can be a bit tough if you're as used to typing screen -r as I am, so I suggest creating an alias. sru works well.

How do I modify the default ANSI colors?

Use Mike Solomon's TerminalColors utility.

An always up–to–date version of this guide can be found here: Setting up the Mac OS X 10.4 Terminal.app
    •    
  • Currently 2.86 / 5
  You rated: 1 / 5 (7 votes cast)
 
[68,231 views]  

A guide to help set up Terminal | 20 comments | Create New Account
Click here to return to the 'A guide to help set up Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A guide to help set up Terminal
Authored by: Spartacus on Aug 28, '06 08:26:27AM

I would love it if someone would post a similar hint for tcsh users. tcsh was the default shell in the first versions of Mac OS X and I have gotten used to it, especially with all the nice presets you can find in /usr/share/tcsh/examples/, but its way of stumbling on Unicode input drives me nuts.

Example:

1. type asdf
2. scroll to the beginning of the line with the left arrow key
3. scroll to the end of the line with the right arrow key
4. repeat 2 and 3 a couple of times
5. display is all messed up



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: weitzman on Aug 28, '06 09:40:11AM

Huh? My Terminal has color management with full picker in Terminal => Window settings menu. Kinda hidden



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: gklinger on Aug 28, '06 10:04:37AM

Yes, Terminal has a colour picker which lets you change the color of the cursor, selection, normal text, bold text and background. However, what if you want to change the default ANSI colors because, for instance, the blue is very dark and you can't see it well on your monitor? You're out of luck. That's where TerminalColors comes in. Install it and you'll see how it works.



[ Reply to This | # ]
Two Comments
Authored by: googoo on Aug 28, '06 09:42:46AM
Thanks for the useful hint. I have two comments. (Perhaps I am missing something.) First, I noticed that Terminal.app maps the forward-delete key to \004 by default. If I add the following line to my .inputrc file, I get the expected forward-delete behavior.

"\004": forward-backward-delete-char

Just do not press the forward-delete key with no text in the command line. It logs you out (just like pressing ctrl-d).

The second comment is that I get error messages when I enter source ~/.inputrc because bash tries to associate thekeymappings with commands. Is there another way to reapply the .inputrc file?

-Mark



[ Reply to This | # ]
Two Comments
Authored by: mietek on Aug 28, '06 03:17:35PM

Yes, just close the Terminal window and open a new one.



[ Reply to This | # ]
Two Comments
Authored by: googoo on Aug 29, '06 05:36:52AM

What I meant was how do you re-read the .initrc file without exiting the shell?

-Mark



[ Reply to This | # ]
Correction
Authored by: googoo on Aug 29, '06 05:41:41AM
I am sorry, but I should not try to type before having coffee. I meant, how do you re-read the .inputrc file without exiting the shell?

-Mark



[ Reply to This | # ]
Solution
Authored by: googoo on Aug 29, '06 05:50:34AM
I found the answer by reading the bash man page (imagine that?). Use the following command.

bind -f ~/.inputrc

You can substitute another filename to read keymaps from that file.

-Mark



[ Reply to This | # ]
thanks plus a (worse) solution
Authored by: vike on Aug 04, '09 05:30:32PM
ive read that manual a lot but you know, its oh so long and, many subjects are discussed at multiple occasions.
so thanks for that one i had missed.
it will probably come to replace my previous inputrc key-binding:
  control-r: re-read-init-file

[ Reply to This | # ]
A guide to help set up Terminal
Authored by: gklinger on Aug 28, '06 10:25:28AM

BTW, as long as people are setting up an .inputrc they might think about adding the following:

"\e[5C": forward-word
"\e[5D": backward-word

That will let them use ctrl + left or right cursor to move through words at the command line. I fiind it to be a big time saver. While I'm at it, the following is good too:

set completion-ignore-case On

It turns on case insensitivity for tab-completition (for example, hitting d + tab finds your Document directory).

Getting your shell setup 'just right' takes time but it's well worth it in the time it will end up saving you.



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: wpaulson on Aug 28, '06 02:19:34PM

In the 10.3 Terminal.app, the "\033" in the keyboard pane isn't needed. That is, rather than "\033[3~" all that's needed is "[3~". I don't know if this differs from 10.4. behavior.



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: cyflea on Sep 04, '06 04:22:32AM

why not configure screen properly while you're at it?

defutf8 on



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: mietek on Sep 06, '06 02:33:00PM

This isn't enough for Screen version 4.00.02 (FAU) 5-Dec-03, which is in debian-stable.



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: teras on Sep 06, '06 04:44:23PM

When I use this hint, backspace in vi is not usable any more. Instead it produces a ^? character.
Any ideas about it?



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: teras on Sep 06, '06 05:13:49PM

I found out that if I don't use stty erase ^H in .profile, backspace works fine in vi



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: sava on Nov 20, '06 03:00:23PM
Put in your vimrc
im ^? ^H
For ^? type backspace and for ^h type ctrl+h ctrl+v

[ Reply to This | # ]
A guide to help set up Terminal
Authored by: sava on Nov 20, '06 03:01:52PM

I mean ctrl+v ctrl+h



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: Christoph on Sep 07, '06 06:27:53AM

Does anyone know how the HOME and END keys (fn + ArrowLeft and fn + ArrowRight on iBook keyboards) can be enabled in Terminal?

This is one of the reasons why I still use xterm instead of Terminal.app.



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: vocaro on Sep 19, '06 03:33:12PM

Shift + fn + ArrowLeft and Shift + fn + ArrowRight



[ Reply to This | # ]
A guide to help set up Terminal
Authored by: sava on Nov 20, '06 01:14:36PM
..or in set in 'Keyboard' of Terminal inspector
end \033F[
home \033H[


[ Reply to This | # ]