• Tip Jar

Console Keyboard Shortcuts

People have been asking about keyboard shortcuts from the console. They do exist, and are very powerful. To create the shortcuts, you need to edit your ~/.inputrc file. These shortcuts are available in the terminal, not in applications. So, your shortcut won’t work inside Linphone for example. The following is a setup that will create keyboard shortcuts for the musicl player XMMS2, including a soft volume control, so your whole computer doesn’t drop or rise in volume with the music. Before using the volume controls you need to enter this in your terminal:

nyxmms2 server config effect.order.0 equalizer
nyxmms2 server config equalizer.enabled 1

You may notice that each of the following shortcuts end with \C-M. This is what appends a new line to the command, it’s the same as pressing enter when you’re done typing. Without it, the command would just sit there, looking all purdy, but not really doing anything. And now, here are the lines you can add to your ~/.inputrc for XMMS2 controls:

"\ez":"nyxmms2 prev&&sleep 0.5&&nyxmms2 current\C-M"
"\ex":"nyxmms2 play&&nyxmms2 current\C-M"
"\ec":"nyxmms2 toggle&&nyxmms2 current\C-M"
"\ev":"nyxmms2 stop\C-M"
"\eb":"nyxmms2 next&&sleep 0.5&&nyxmms2 current\C-M"
"\e-":"nyxmms2 server config equalizer.preamp $(($(nyxmms2 server config equalizer.preamp | tr -Cd \"[:digit:]-\") - 5))\C-M"
"\e=":"nyxmms2 server config equalizer.preamp $(($(nyxmms2 server config equalizer.preamp | tr -Cd \"[:digit:]-\") + 5))\C-M"

As you can see, the format is "key":"command". The \e means to use alt as a modifier. Here is a nifty little table that shows the keybindings for the code above.

Key Action
Alt+z previous track
Alt+x play
Alt+c pause
Alt+v stop
Alt+b next track
Alt+- volume down
Alt+- volume up

If you want to use the control key in your keyboard shortcut, simply replace \e\C like so:

"\C-t":"\C-k \C-utalking-clock -c &> /dev/null\n" #speak time control+t

And there you have it, keyboard shortcuts in the console. These are very useful, I have a lot of them in my ~/.inputrc and use most of them every day.

Bookmark the permalink.

Comments are closed.

  • Tip Jar