Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 12162  / 2 Years ago, tue, september 27, 2022, 1:11:50

I would like to change the default shortcut to switch back and forth to the tty. By default it is ctrl + alt + F#. I have tried making a custom shortcut using Ubuntu's keyboard settings but it only worked while using the graphical interface when i switch back to tty it doesn't work. So I need to figure out how to change the default binding of the ctrl + alt + F# shortcut to make a single key toggle back and forth between two TTYs.


More From » 12.04

 Answers
3

You can use bind to bind a key to some function. Here is what I did:



bind '"ea": ". ~/newScript.sh
" '


Here newScript.sh is the file which changes the tty and ea means that whenever Alt+A is pressed, the script executes.



The contents of newScript.sh are:



#! /bin/bash
ttyNum="$(tty)"
ttyNum=$(echo ${ttyNum##*y})
ttyNum=$(( (ttyNum +1) % 7))
chvt $ttyNum


Note that if you want to store the key bindings permanently, you can store them in your `~/.inputrc' file. For more information, you can visit this link: http://www.techrepublic.com/article/find-and-bind-key-sequences-in-bash/5683375



Update: You can store the bind line in your ~/.bashrc file so that you don't have to do it again.


[#37832] Thursday, September 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
calcur

Total Points: 189
Total Questions: 80
Total Answers: 95

Location: Burkina Faso
Member since Thu, Dec 15, 2022
1 Year ago
;