In most places on macOS the Ctrl-Left key makes the cursor go to the beginning of the line. But in the terminal, when I press Ctrl-Left it puts in the following
To change this, if one is using bash, we can use the
bind command. You can type bind -p to see all the keyboard bindings in bash (thanks to this blog post).
I need to map Ctrl-Left to the
beginning -of-line function.
If I open Terminal and go to the Keyboard section I see Ctrl-Left is mapped as
So all I need do is the following two commands (one for beginning of line, another for end).
bind '"\033[1;5C": end-of-line'<br />bind '"\033[1;5D": beginning-of-line'
Add these to
.bashrc and it’s always bound in every new session.
While in the Keyboards section also tick the “Use Option as Meta key”. This lets you use the Alt/ Option key in the Terminal. So I can do Alt-Left and Alt-Right to go back and forth one word.