Creating Keyboard Shortcuts

A number of keyboard shortcuts are at your disposal. You learned about several of them in Useful Shortcuts. For example you learned that Ctrl+l clears the screen, and Ctrl+a jumps to the beginning of the line. Use the bind -p command to see a list of all the defined commands available. It’s a long list, so use less:

 $ ​​bind​​ ​​-p​​ ​​|​​ ​​less
 "\C-g": abort
 "\C-x\C-g": abort
 "\e\C-g": abort
 "\C-j": accept-line
 "\C-m": accept-line
 ...

In addition to the ones already defined, you can make your own. Try it out by using the bind command to map Ctrl+t to execute the pwd command:

 $ ​​bind​​ ​​'"\C-t": "pwd\n"'

Note a couple things about this. First, you need single quotes around the keybinding definition. ...

Get Small, Sharp Software Tools now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.