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).
033 [ 3 ~
from od. Then usebindkey "^[[3~" delete-char
to bind what Terminal sends to a function in zsh. Does that not work for you?bindkey "^[[3~" delete-char
into my ~/.profile, restarted Terminal, and tells me it doesn't knowbindkey
. 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... :)dscl . read /Users/$USER UserShell
. The default is bash. You can change your default shell withchsh -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
).