Matt Brown – Journeys of a software engineer

April 3, 2009

Doskey like tab completion and various other fixes /power user hacks for the mac console prompt (ctrl-left,right arrow)

Filed under: console, Keyboard — Tags: , — mattbsoftware @ 12:55 am

Want to have the same keystrokes (plus more) that are seen in M$ command/doskey or cmd on the mac console? Especially ctrl-left-arrow, ctrl-right-arrow. I did. Many years ago (Slackware v2) I started this .inputrc and have since updated and translated it for the mac console (Terminal.App).

For additional help “man bash” and search for “bind”. You will find the definitions of the commands in .inputrc (i.e. menu-complete). See the links at the end of the included .inputrc for additional help. These instructions are for the console, look here for fixing home and end in regular mac GUI applications: If your really curious about how all this works, “man stty”

This first part focuses on home and end, I put comments in the .inputrc that will explain all the other cool keystrokes.

Only two Steps:

  1. Change keybindings in Terminal.App
  2. Create/add to .inputrc


1. Change keybindings in Terminal.App
Goto Terminal’s Preferences. Select Keyboard. Find the end key and click Edit. Change the end key’s action to “send to string to shell”. You’ll notice that backspace/delete do not work properly. Use the Delete One Character button to backspace. Set the string to “\33[4~”

I had some issues typing the “\” character in the string to send edit box so I cut-n-pasted from some other random key and just changed the trailing end of the keycode.

Do the same thing for the home key, except use “\33[1~”. When your done Terminal’s preference’s should look something like this:

2. Drop this into ~/.inputrc ———————–————BOF
#”\e[11~”: “Function Key 1”
#”\e[12~”: “Function Key 2”
#”\e[13~”: “Function Key 3”

#”\e[14~”: “Function Key 4”
#”\e[15~”: “Function Key 5”
#”\e[17~”: “Function Key 6”
#”\e[18~”: “Function Key 7”
#”\e[19~”: “Function Key 8”
#”\e[20~”: “Function Key 9”
#”\e[21~”: “Function Key 10”

# For Bash, all terminals, add some Bash specific hacks.
$if Bash
“\C-xv”: show-bash-version
“\C-x\C-e”: shell-expand-line

### fix delete key
“\e[3~”: delete-char

## END key — MAC must be remapped in Terminal options (keyboard) “33[4~”
## HOME key — MAC must be remapped in Terminal options (keyboard) “33[1~”
“\e[1~”: beginning-of-line


# For FTP, different hacks:
$if Ftp
“\C-xg”: “get \M-?”
“\C-xt”: “put \M-?”
“\M-.”: yank-last-arg

” “: self-insert

$if Bash

# ctrl-backspace – none of this ever worked 😦 — use ctrl-w instead (default)
### never worked –>”\e\C-[D”: backward-kill-word
### Control-Rubout: backward-kill-word
##Map control-foward-delete to F14 “33[26~”
##”\e[26~”: backward-kill-word

#### doskey like completion
set completion-ignore-case On
“\e[A”: history-search-backward
“\e[B”: history-search-forward

#### doskey like line movement
#ctrl-left arrow
“\e[5D”: backward-word
#ctrl-right arrow
“\e[5C”: forward-word

# auto list tab completions
set show-all-if-ambiguous on

# show a filetype indicator in tab completions
set visible-stats on

## tab cycles through completions — I like the show-all-if-ambiguous instead
#”\t”: menu-complete
## shift-tab to reverse cycle complete
#\C-y: “\e–\C-i”

### didn’t like this
#Space: magic-space


# Include system wide settings which are ignored by default if one has their own .inputrc
$include /etc/inputrc

##helpful sites

If ~/.inputrc doesn’t work, then you need to add

export INPUTRC=~/.inputrc

to your .bashrc/.bash_profile

If your wondering why I am bother with home/end it’s because I use a M$ ergo keyboards on my macs. Why doesn’t Apple make one an ergonomic keyboard?

PS: Read-line keys natively work in man mac apps (ctrl+e for end / ctrl+a for end / ctrl+k for kill line, etc)


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

%d bloggers like this: