Is there a way to enable Ctrl + ← / → keyboard shortcuts (go to previous / next word) in the Bash console installed with MSysGit?
7 Answers
At your Bash prompt, press Ctrl-v Ctrl-Left-Arrow and Ctrl-v Ctrl-Right-Arrow and make note of the output. You should see something like: ^[OD
and ^[OC
or similar. Add the following lines to your ~/.inputrc
:
"\eOC": forward-word
"\eOD": backward-word
where you will substitute \e
for escape (^[
) and the rest of the characters you got (OD
, OC
or similar).
To re-read the file and make the changes active immediately, press Ctrl-x Ctrl-r.

- 346,391
- 90
- 374
- 439
I found this answer by tan on AskUbuntu, which worked for me after none of these answers did. I'll repost it here.
What is in your ~/.inputrc
and /etc/inputrc
? The minimum to get those keys working is, I think:
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
If you have these in /etc/inputrc
, the file needs to be included from ~/.inputrc
, so check that it has the following line:
$include /etc/inputrc

- 1
- 1

- 8,312
- 2
- 43
- 57
-
1You totally nailed it with the `$include /etc/inputrc`. I've created a keyboard shortcut in my `~/.inputrc` (just for fun) and been screwed ever since, because creating the file in my home skipped the `/etc/inputrc` as a default. Thx from the future. – kub1x Jun 28 '17 at 13:52
-
6This works for the MINGW64 client ("Git Bash" in Git for Windows) as well! – klaar Nov 15 '17 at 11:19
-
This works for macOS (Mojave, don't know if it counts) terminal as well, thanks ! – Pierre-Olivier Vares Dec 18 '18 at 10:37
Not really answering your question, but you can try ALT-F and ALT-B instead.

- 26,473
- 4
- 65
- 84
Adding to my ~/.inputrc
"\e[1;5C": forward-word
"\e[1;5D": backward-word
Was enough for me.

- 2,999
- 3
- 28
- 23
This worked for me in Windows 7:
Add this to the ~/.inputrc
Then restart the console and it should work for you.
This makes it so you can do either use
CTRL+← or CTRL+→
Or
ALT+← or ALT+→
## Windows msysgit
## Alt + right/left
"\e\e[C": forward-word ### Alt + right
"\e\e[D": backward-word ### Alt + left
## Ctrl + right/left
"\e[C": forward-word ### Ctrl + right
"\e[D": backward-word ### Ctrl + left

- 293
- 1
- 5
- 10
For those confused on why it is not working for the ctrl+Left-Arrow and ctrl+Right-Arrow.
This is because of a bug with windows 7, maybe others, and msys where the ctrl key would not be recognized (at least for my case).
To check if you are in the same situation, do what @Dennis say:
- Open terminal
- Make sure ctrl+v has not been remapped to something else
- Press ctrl+v followed by ctrl+Left-Arrow to check the key sequence
- Look at the output
Repeat with only pressing the Left-Arrow.
If they are identical, welcome to my world. You can now use Autohotkey to remap the keys or use the newer windows git bash.

- 793
- 1
- 7
- 20
I edited the file /etc/inputrc:
sudo gedit /etc/inputrc
and commented out the following lines:
$if term=rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
$endif
Then I edited the file ~/.bashrc:
sudo gedit ~/.bashrc
and added the following lines at the bottom:
#### enable Ctrl+Left , Ctrl+Right keybindings:
bind '"\e[1;5C":forward-word' # Ctrl+Right
bind '"\e[1;5D":backward-word' # Ctrl+Left
It seems to work and, at least so far, without side effects.
(tested on Ubuntu GnomeShell Remix 12.04 AMD64)

- 11
- 2