Why is Ctrl-Arrow not working in bash on OS X?
I use Ctrl-← and Ctrl-→ on every Linux system I work on, but these key combinations don't work in bash on my Macbook Pro. It is running Snow Leopard, and I'm using the built in Terminal application.
The key combinations don't seem to be captured by anything before or by Terminal, because if I ssh to one of my Linux servers, I can use Ctrl-←/→ to jump to the next/previous word on the command line. However, when I try this key combination in bash on my Macbook, I just get "C" for right arrow and "D" for left arrow.
Any ideas on how I can get these keys to work in darwin bash?
macos bash
add a comment |
I use Ctrl-← and Ctrl-→ on every Linux system I work on, but these key combinations don't work in bash on my Macbook Pro. It is running Snow Leopard, and I'm using the built in Terminal application.
The key combinations don't seem to be captured by anything before or by Terminal, because if I ssh to one of my Linux servers, I can use Ctrl-←/→ to jump to the next/previous word on the command line. However, when I try this key combination in bash on my Macbook, I just get "C" for right arrow and "D" for left arrow.
Any ideas on how I can get these keys to work in darwin bash?
macos bash
2
If you are using Spaces, Ctrl + arrow by default switches spaces.
– mark4o
Oct 31 '10 at 21:19
1
Similar
– Dennis Williamson
Oct 31 '10 at 21:36
add a comment |
I use Ctrl-← and Ctrl-→ on every Linux system I work on, but these key combinations don't work in bash on my Macbook Pro. It is running Snow Leopard, and I'm using the built in Terminal application.
The key combinations don't seem to be captured by anything before or by Terminal, because if I ssh to one of my Linux servers, I can use Ctrl-←/→ to jump to the next/previous word on the command line. However, when I try this key combination in bash on my Macbook, I just get "C" for right arrow and "D" for left arrow.
Any ideas on how I can get these keys to work in darwin bash?
macos bash
I use Ctrl-← and Ctrl-→ on every Linux system I work on, but these key combinations don't work in bash on my Macbook Pro. It is running Snow Leopard, and I'm using the built in Terminal application.
The key combinations don't seem to be captured by anything before or by Terminal, because if I ssh to one of my Linux servers, I can use Ctrl-←/→ to jump to the next/previous word on the command line. However, when I try this key combination in bash on my Macbook, I just get "C" for right arrow and "D" for left arrow.
Any ideas on how I can get these keys to work in darwin bash?
macos bash
macos bash
edited Jul 25 '16 at 6:15
Hennes
59k792141
59k792141
asked Oct 31 '10 at 17:02
Ryan OlsonRyan Olson
3891715
3891715
2
If you are using Spaces, Ctrl + arrow by default switches spaces.
– mark4o
Oct 31 '10 at 21:19
1
Similar
– Dennis Williamson
Oct 31 '10 at 21:36
add a comment |
2
If you are using Spaces, Ctrl + arrow by default switches spaces.
– mark4o
Oct 31 '10 at 21:19
1
Similar
– Dennis Williamson
Oct 31 '10 at 21:36
2
2
If you are using Spaces, Ctrl + arrow by default switches spaces.
– mark4o
Oct 31 '10 at 21:19
If you are using Spaces, Ctrl + arrow by default switches spaces.
– mark4o
Oct 31 '10 at 21:19
1
1
Similar
– Dennis Williamson
Oct 31 '10 at 21:36
Similar
– Dennis Williamson
Oct 31 '10 at 21:36
add a comment |
3 Answers
3
active
oldest
votes
OS X uses emacs key binding my default. This is true is virtually every application on OS X, it's rather nice. It means things like C-a and C-e are beginning/end of line. You also get the nifty backward-word-kill with M-backspace, oh, and kill-line with C-k.
This should mean that in your terminal forward/backward-word are bound to M-f and M-b, respectively (M = Meta = alt/option), however that is not the case. On OS X forward/backword-word are bound to M-→ and M-← by default.
You can alter this behavior by changing how the GNU Readline Library is configured for your account. This takes place in your ~/.inputrc
file. You can get a big list of bindable commands with man readline
as well as in the online documentation like this here..
So to answer your question, you want to remap what Readline does when it sees C-→ and C-← to do what it does on your linux server.
The syntax for a ~/.inputrc
file is pretty simple for what you want to do: key-sequence: action
.
This should be what you need to get the desired behavior:
"e[5C": forward-word
"e[5D": backward-word
Here's another page with additional useful bindings.
(You could probably get away with copying /etc/inputrc from your linux box to your OS X ~/.inputrc)
A note: If you are using tmux with xterm-keys a lot, you will also neede[1;5C
ande[1;5D
to also triggerforward-word
andbackward-word
.
– Arne
Jan 26 '14 at 10:45
1
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
add a comment |
put in ~/.inputrc
following lines:
"e[5C": forward-word
"e[5D": backward-word
add a comment |
These days it seems that the escape sequences that Ctrl-Arrows output in the terminal have changed. Here is what works for me as of today (end of 2018):
"e[1;5C": forward-word
"e[1;5D": backward-word
Note: you can always figure out the actual escape sequences by typing cat -v
in the Terminal, and pressing Ctrl-Left Arrow or Ctrl-Right Arrow. Here is a sample output for my own Ctrl-Left Arrow:
^[[1;5C
^[[1;5C
To translate into .inputrc
lingo, replace the escape sign ^[
with e
and stick the result inside the double quotes.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f205470%2fwhy-is-ctrl-arrow-not-working-in-bash-on-os-x%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
OS X uses emacs key binding my default. This is true is virtually every application on OS X, it's rather nice. It means things like C-a and C-e are beginning/end of line. You also get the nifty backward-word-kill with M-backspace, oh, and kill-line with C-k.
This should mean that in your terminal forward/backward-word are bound to M-f and M-b, respectively (M = Meta = alt/option), however that is not the case. On OS X forward/backword-word are bound to M-→ and M-← by default.
You can alter this behavior by changing how the GNU Readline Library is configured for your account. This takes place in your ~/.inputrc
file. You can get a big list of bindable commands with man readline
as well as in the online documentation like this here..
So to answer your question, you want to remap what Readline does when it sees C-→ and C-← to do what it does on your linux server.
The syntax for a ~/.inputrc
file is pretty simple for what you want to do: key-sequence: action
.
This should be what you need to get the desired behavior:
"e[5C": forward-word
"e[5D": backward-word
Here's another page with additional useful bindings.
(You could probably get away with copying /etc/inputrc from your linux box to your OS X ~/.inputrc)
A note: If you are using tmux with xterm-keys a lot, you will also neede[1;5C
ande[1;5D
to also triggerforward-word
andbackward-word
.
– Arne
Jan 26 '14 at 10:45
1
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
add a comment |
OS X uses emacs key binding my default. This is true is virtually every application on OS X, it's rather nice. It means things like C-a and C-e are beginning/end of line. You also get the nifty backward-word-kill with M-backspace, oh, and kill-line with C-k.
This should mean that in your terminal forward/backward-word are bound to M-f and M-b, respectively (M = Meta = alt/option), however that is not the case. On OS X forward/backword-word are bound to M-→ and M-← by default.
You can alter this behavior by changing how the GNU Readline Library is configured for your account. This takes place in your ~/.inputrc
file. You can get a big list of bindable commands with man readline
as well as in the online documentation like this here..
So to answer your question, you want to remap what Readline does when it sees C-→ and C-← to do what it does on your linux server.
The syntax for a ~/.inputrc
file is pretty simple for what you want to do: key-sequence: action
.
This should be what you need to get the desired behavior:
"e[5C": forward-word
"e[5D": backward-word
Here's another page with additional useful bindings.
(You could probably get away with copying /etc/inputrc from your linux box to your OS X ~/.inputrc)
A note: If you are using tmux with xterm-keys a lot, you will also neede[1;5C
ande[1;5D
to also triggerforward-word
andbackward-word
.
– Arne
Jan 26 '14 at 10:45
1
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
add a comment |
OS X uses emacs key binding my default. This is true is virtually every application on OS X, it's rather nice. It means things like C-a and C-e are beginning/end of line. You also get the nifty backward-word-kill with M-backspace, oh, and kill-line with C-k.
This should mean that in your terminal forward/backward-word are bound to M-f and M-b, respectively (M = Meta = alt/option), however that is not the case. On OS X forward/backword-word are bound to M-→ and M-← by default.
You can alter this behavior by changing how the GNU Readline Library is configured for your account. This takes place in your ~/.inputrc
file. You can get a big list of bindable commands with man readline
as well as in the online documentation like this here..
So to answer your question, you want to remap what Readline does when it sees C-→ and C-← to do what it does on your linux server.
The syntax for a ~/.inputrc
file is pretty simple for what you want to do: key-sequence: action
.
This should be what you need to get the desired behavior:
"e[5C": forward-word
"e[5D": backward-word
Here's another page with additional useful bindings.
(You could probably get away with copying /etc/inputrc from your linux box to your OS X ~/.inputrc)
OS X uses emacs key binding my default. This is true is virtually every application on OS X, it's rather nice. It means things like C-a and C-e are beginning/end of line. You also get the nifty backward-word-kill with M-backspace, oh, and kill-line with C-k.
This should mean that in your terminal forward/backward-word are bound to M-f and M-b, respectively (M = Meta = alt/option), however that is not the case. On OS X forward/backword-word are bound to M-→ and M-← by default.
You can alter this behavior by changing how the GNU Readline Library is configured for your account. This takes place in your ~/.inputrc
file. You can get a big list of bindable commands with man readline
as well as in the online documentation like this here..
So to answer your question, you want to remap what Readline does when it sees C-→ and C-← to do what it does on your linux server.
The syntax for a ~/.inputrc
file is pretty simple for what you want to do: key-sequence: action
.
This should be what you need to get the desired behavior:
"e[5C": forward-word
"e[5D": backward-word
Here's another page with additional useful bindings.
(You could probably get away with copying /etc/inputrc from your linux box to your OS X ~/.inputrc)
answered Oct 31 '10 at 19:16
Tim BielawaTim Bielawa
93076
93076
A note: If you are using tmux with xterm-keys a lot, you will also neede[1;5C
ande[1;5D
to also triggerforward-word
andbackward-word
.
– Arne
Jan 26 '14 at 10:45
1
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
add a comment |
A note: If you are using tmux with xterm-keys a lot, you will also neede[1;5C
ande[1;5D
to also triggerforward-word
andbackward-word
.
– Arne
Jan 26 '14 at 10:45
1
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
A note: If you are using tmux with xterm-keys a lot, you will also need
e[1;5C
and e[1;5D
to also trigger forward-word
and backward-word
.– Arne
Jan 26 '14 at 10:45
A note: If you are using tmux with xterm-keys a lot, you will also need
e[1;5C
and e[1;5D
to also trigger forward-word
and backward-word
.– Arne
Jan 26 '14 at 10:45
1
1
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
Another note: If still not working, it may be because of a shortcut conflict with Mission Control/Spaces. System Preferences -> Keyboard -> Shortcuts -> Mission Control, Move left/right a space
– bhh1988
Jul 7 '14 at 5:25
add a comment |
put in ~/.inputrc
following lines:
"e[5C": forward-word
"e[5D": backward-word
add a comment |
put in ~/.inputrc
following lines:
"e[5C": forward-word
"e[5D": backward-word
add a comment |
put in ~/.inputrc
following lines:
"e[5C": forward-word
"e[5D": backward-word
put in ~/.inputrc
following lines:
"e[5C": forward-word
"e[5D": backward-word
answered Oct 31 '10 at 18:02
tigtig
2,73132647
2,73132647
add a comment |
add a comment |
These days it seems that the escape sequences that Ctrl-Arrows output in the terminal have changed. Here is what works for me as of today (end of 2018):
"e[1;5C": forward-word
"e[1;5D": backward-word
Note: you can always figure out the actual escape sequences by typing cat -v
in the Terminal, and pressing Ctrl-Left Arrow or Ctrl-Right Arrow. Here is a sample output for my own Ctrl-Left Arrow:
^[[1;5C
^[[1;5C
To translate into .inputrc
lingo, replace the escape sign ^[
with e
and stick the result inside the double quotes.
add a comment |
These days it seems that the escape sequences that Ctrl-Arrows output in the terminal have changed. Here is what works for me as of today (end of 2018):
"e[1;5C": forward-word
"e[1;5D": backward-word
Note: you can always figure out the actual escape sequences by typing cat -v
in the Terminal, and pressing Ctrl-Left Arrow or Ctrl-Right Arrow. Here is a sample output for my own Ctrl-Left Arrow:
^[[1;5C
^[[1;5C
To translate into .inputrc
lingo, replace the escape sign ^[
with e
and stick the result inside the double quotes.
add a comment |
These days it seems that the escape sequences that Ctrl-Arrows output in the terminal have changed. Here is what works for me as of today (end of 2018):
"e[1;5C": forward-word
"e[1;5D": backward-word
Note: you can always figure out the actual escape sequences by typing cat -v
in the Terminal, and pressing Ctrl-Left Arrow or Ctrl-Right Arrow. Here is a sample output for my own Ctrl-Left Arrow:
^[[1;5C
^[[1;5C
To translate into .inputrc
lingo, replace the escape sign ^[
with e
and stick the result inside the double quotes.
These days it seems that the escape sequences that Ctrl-Arrows output in the terminal have changed. Here is what works for me as of today (end of 2018):
"e[1;5C": forward-word
"e[1;5D": backward-word
Note: you can always figure out the actual escape sequences by typing cat -v
in the Terminal, and pressing Ctrl-Left Arrow or Ctrl-Right Arrow. Here is a sample output for my own Ctrl-Left Arrow:
^[[1;5C
^[[1;5C
To translate into .inputrc
lingo, replace the escape sign ^[
with e
and stick the result inside the double quotes.
answered Dec 30 '18 at 11:48
DomQDomQ
1315
1315
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f205470%2fwhy-is-ctrl-arrow-not-working-in-bash-on-os-x%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
If you are using Spaces, Ctrl + arrow by default switches spaces.
– mark4o
Oct 31 '10 at 21:19
1
Similar
– Dennis Williamson
Oct 31 '10 at 21:36