I use a Mac at home and have changed my modifier keys swapping Command and CTRL, so CTRL+T spawns a new tab in chrome, CTRL+C is copy and so forth. I use Windows/Linux at work and I want a consistent layout between these OSes (not having to consciously switch to Command on OSX and back to CTRL when at work).

I've installed iTerm2 to replace OSX Terminal, this allows me to capture CTRL+W without having it kill the window. I don't know what to bind this shortcut to in order to emulate the default behaviour in bash/puTTY (werase?) where it deletes text before the cursor up to the first space.

find . -name "my.file" -type

CTRL+W would delete '-type' from the above command leaving:

find . -name "my.file"
  • How about all the other commands? Most of ⌃A-Z and ⌘A-Z are already bound to some action at least in iTerm and Terminal.
    – Lri
    Dec 18 '11 at 11:30

Put this line, quotes and all, in your ~/.inputrc file (you may have to restart Bash after you edit that file):

"\C-w": backward-kill-word
  • Doesn't answer the question, as the user swapped control and command, meaning he actually wants to handle command-w.
    – Daniel Beck
    May 21 '12 at 17:13
  • @GregK If your CTRL key can do other things you expect to work in Bash (e.g., CTRL-B moves the cursor back one character) then I believe my answer above will work for you. If not, then Daniel is right.
    – Fran
    May 21 '12 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.