How to Set Terminal Beginning-of-Line Keyboard Shortcut
Answered
I want to be able to use `command + left` to go to the beginning of the line when using the embedded local terminal. How would I set this up? Couldn't find an option for this listed in the settings.
Please sign in to leave a comment.
Unfortunately you can't configure it in PyCharm, you have to customise your shell's hotkeys globally for you system. Do you use bash/zsh/fish?
I use bash.
It looks like PyCharm already remaps `Command+Left Arrow` to `Alt+Left Arrow`, which has a current key binding to `backward-word`. So if I setup a custom key binding in an .inputrc file that remapped `Alt+Left Arrow` to `beginning-of-line`, I would loose the default `Alt+Left Arrow` to `backward-word` key binding, which I want to preserve.
I found a solution by using Keyboard Maestro. I set up an application specific macro (PyCharm only) that remaps `Command+Left Arrow` to `Ctrl+A`. This fixes the issue when using the terminal, and since PyCharm's default settings have a keymap binding `Ctrl+A` to `Move Caret to Line Start`, `Ctrl+A` works the same as the original `Command+Left Arrow` did for the rest of the application, so the change is unnoticeable when using the other parts of the application.
Let me know if there is an easier way to do this without using something like Keyboard Maestro.
I press command+left will type "OD" in the console, and after I add these in my ~/.zshrc, I solved it.
```
bindkey "\e\eOD" beginning-of-line
bindkey "\e\eOC" end-of-line
```
Don't forget to execute `zsh` to apply it.
Qz1578 Thanks for the suggestion! I had to modify my key bindings a bit (maybe because I'm on macOS, not sure), but here's what worked for me:
Thanks for pointing me in the right direction.