How to setup keyboard shortcuts in Ubuntu Linux by modifying multiple config files and settings after searching the internet for the answers for years
I am using Ubuntu 22.04, Bash 5.1.16
What I want:
- ctrl-c for copy. The default for copying is ctrl+shift+c, I found myself sometimes pressing this trio of keys in other programs. How embarassing.
- ctrl-v for paste.
- some replacement for ctrl-c to send sigint (I used ctrl-k).
- ctrl-space to delete the current word
- ctrl+up moves cursor to the beginning of the line (which is up on multi-line commands).
- ctrl+down moves the cursor to the end of the line (which is down on multi-line commands).
Oh yeah, and make the key repeat super fast so that I can delete a whole line by pressing backspace for a second. Thats one way to do it.
So, anyway I found out how to do this stuff!
Set the copy and paste shortcuts in the terminal app (gnome-terminal). It is in the menu: Preferences->Shortcuts .
I added this to my ~/.bashrc file to replace the previous function of ctrl-c:
# Set ctrl-k to send the interrupt signal because I have set
# ctrl-c,ctrl-v to copy,paste in the terminal app.
stty intr \^k
Make a file "~/.inputrc" and put this stuff in it:
$include /etc/inputrc
# alt+up or ctrl+up
"\033[1;5A": beginning-of-line
"\033[1;3A": beginning-of-line
# ctrl+down or alt+down
"\033[1;5B": end-of-line
"\033[1;3B": end-of-line
# ctrl+space : delete current word
"\000": kill-word
If you ever want to find out the keycode (thats this part: "\033[1;5A"
), enter the terminal command:
sed -n l
(that is a lowercase L, it is not a number one!) then press whatever key combination that you want to find the keycode for. Press enter. Copy the text that gets output (It will be slightly different than what was displayed when you typed).
If you want to set shortcuts for different functions, enter the command:
bind -l
and it will print a list of all of the available functions with no explaination. You have to look up what they do or you could just stop now. That's what I did.
Ok, the last thing on the list is keyboard repeat speed. Use the 'Settings' app. It is in there at the 'Accessibility' section. I was going to circle the place that you have to click. I was going to use a red pen and circle it, but when I started up the Gnu Image Modification Program, it was in black and white. The whole thing was in black and white. The screenshot and the user interface was in in black and white! A quick internet search shows that someone else had the same problem and got no help. So I'm going to uninstall the Gnu Image Manipulation Program and move on.
Click on the part that says "Repeat Keys"
A modal submenu will pop-up and you can edit the settings from there.
I had been meaning to do this for a long time, just never got around to it. It sure makes things easier for me to have just a few simple keyboard shortcuts of my choosing.
So, yeah, I did all this stuff and it changed my life.