I'd like the delete key (well, the Fn+Backspace combination) on my Mac to behave the same way in the Terminal as it does normally. That is, to do forward-delete. Right now it outputs tilde - at least that's what I can see.

In Binding Fn-Delete in zsh on Mac OS X I saw some hackery and tried it too:

(pressed [Fn]+[<---] inside the quotes below)

$ echo "~" | od -c
0000000   ~  \n

How can I make it behave?

  • The comments on SU 169930 seem fairly clear: You should be using Control-v before pressing Fn-BackSpace, which will probably show up as 033 [ 3 ~ from od. Then use bindkey "^[[3~" delete-char to bind what Terminal sends to a function in zsh. Does that not work for you? May 26, 2011 at 2:02
  • Tried to add bindkey "^[[3~" delete-char into my ~/.profile, restarted Terminal, and tells me it doesn't know bindkey. Added it into .zshrc, restarted Terminal, and nothing happens. I don't really think I'm using zsh. Or is it Mac's default shell? I'm an amateur in these things... :) May 26, 2011 at 12:07
  • You can check your shell with dscl . read /Users/$USER UserShell. The default is bash. You can change your default shell with chsh -s /bin/bash. You can change just the shell used in Terminal in its preferences (Settings tool bar button, then Shell tab, change Run Command to (e.g.) /bin/zsh). May 26, 2011 at 13:37
  • Yes, my default is bash. I tried zsh and it seems to work the way I want it to. Does the bash have a way to achieve the same result? May 26, 2011 at 18:09
  • For the csh or tcsh shell, see this link: tomica.net/blog/2017/10/fix-delete-key-in-csh-or-tcsh
    – Alan
    Sep 21, 2022 at 20:08

1 Answer 1


The answer to the question to which you linked shows how to find the control sequence Terminal sends when you press FnBackspace: echo 'ControlV FnBackspace' | od -c.
The ControlV is critical to prevent special interpretation of the (likely) initial ESC character.

Terminal probably sends the four byte sequence ESC [ 3 ~.

The question to which you linked was asking about zsh. The comment on the answer gives the command to bind the sequence in zsh, i.e:

bindkey "^[[3~" delete-char

(usually in ~/.zhsrc).

However, bash is the default shell on Mac OS X, so the command to bind a key (and the functions available for binding) will be different if you are using bash: bind '"\e[3~": delete-char'. You will probably want to put this in a bash startup file1.

If you find that you are using bash, but you want to use zsh instead, then there are two ways to change your effective shell:

  • Use chsh -s /bin/zsh to change your default shell.
    This will change the shell that Terminal starts as well as the shell started for other login sessions (e.g. logins through SSH).
  • Configure just Terminal to use a different shell in Terminal’s preferences.
    Terminal > Preferences…, Settings tool bar button, then the Shell tab,
    change Run Command to (e.g.) /bin/zsh -l.

1 Usually ~/.bashrc, but you can also put a related line ("\e[3~": delete-char) in ~/.inputrc instead. If you put it your .bashrc, you will want to make sure that you also have a line like source ~/.bashrc in ~/.bash_profile, or ~/.bash_login (if you have neither, then create the former; if you already have exactly one of them, then use the one you have; if you have both, then you should fix that since probably only the former is being used).

  • Excellent explanation. Thank you! (oh, and it worked. :) ) May 26, 2011 at 22:06
  • Nice simple answer for me. Just put this in ~/.zshrc on the server
    – itsthejb
    Jan 31, 2017 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .