Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSysGit Bash - how to enable Ctrl+Left / Right arrows?

Is there a way to enable Ctrl + / keyboard shortcuts (go to previous / next word) in the Bash console installed with MSysGit?

like image 465
Borek Bernard Avatar asked Nov 04 '10 08:11

Borek Bernard


5 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.

like image 148
Dennis Williamson Avatar answered Nov 09 '22 09:11

Dennis Williamson


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
like image 24
Cody Piersall Avatar answered Nov 09 '22 08:11

Cody Piersall


Not really answering your question, but you can try ALT-F and ALT-B instead.

like image 15
J-16 SDiZ Avatar answered Nov 09 '22 07:11

J-16 SDiZ


Adding to my ~/.inputrc

"\e[1;5C": forward-word
"\e[1;5D": backward-word

Was enough for me.

like image 7
Treviño Avatar answered Nov 09 '22 07:11

Treviño


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
like image 7
James Affleck Avatar answered Nov 09 '22 07:11

James Affleck