February 4, 2008 at 1:28PM Fixing a FreeBSD annoyance: shell editing keybindings
Unlike all the other systems I use, FreeBSD is lacking in one tiny little area: default shell keybindings. Specifically, there’s no keybindings associated with the arrow keys when CTRL is held down.
I’m used to being able to move back a word with CTRL+LeftArrow is pressed, being able to move forward a word with CTRL+RightArrow, being able to move to the start of the line with CTRL+UpArrow, and being able to move to the start of the line with CTRL+DownArrow, but none of the shells are configured with these bindings by default. There are bindings for the particular functions though, just not these particular ones.
This is a bit of an annoyance, but it’s only recently that I’ve became sufficiently annoyed to fix it. Here’s my zsh bindings, which also work with tcsh:
bindkey '\e[1;5D' backward-word bindkey '\e[1;5C' forward-word bindkey '\e[1;5A' beginning-of-line bindkey '\e[1;5B' end-of-line
Here’s the bash bindings:
bind '"\e[1;5D": backward-word' bind '"\e[1;5C": forward-word' bind '"\e[1;5A": beginning-of-line' bind '"\e[1;5B": end-of-line'
And finally, the FreeBSD sh bindings:
bind "^[[1;5D" ed-prev-word bind "^[[1;5C" ed-next-word bind "^[[1;5A" ed-move-to-beg bind "^[[1;5B" ed-move-to-end
There, fixed.
1 On February 5, 2008 at 12:12, Revence wrote:
I use vi mode in zsh, so I just go even as I would in a Real Editor. I guess you use a different mode? I find vi mode too nice to live without.
Also, you started with zsh ... do you use zsh primarily? Isn’t it a little weird there are people still using bash? :o)
2 On February 6, 2008 at 17:50, Keith wrote:
I might use Vim for all my text editing, but I use emacs modes in my shells: it just feels better for that kind of thing.
I started off with bash, but switched to zsh. bash is a perfectly fine shell, but zsh just works better for me, and it’s less broken than every other shell. I still use bash at work because I have to ssh into servers set up with bash and it’d be disconcerting if I was constantly switching shells.
However, if the machine’s mine, it always has zsh set up as the shell.