Search⌘ K
AI Features

Creating Keyboard Shortcuts

Explore how to view existing keyboard shortcuts and create your own custom keybindings in the shell. Learn to map keys to execute commands and automate frequent tasks, enhancing your command-line workflow. This lesson guides you through setting permanent shortcuts in configuration files for personalized shell control.

List of defined commands

Several keyboard shortcuts are at our disposal. We learned about several of them in Useful Shortcuts. For example, we learned that “Ctrl+l” clears the screen and “Ctrl+a” jumps to the beginning of the line. We can use the bind -p command to see a list of all the defined commands available. It’s a long list, so let’s use less:

$ bind -p | less

Use the terminal below to practice this command.

Terminal 1
Terminal
Loading...

Making our own commands

In addition to the commands already defined, we can make our own. Let’s try it out by using the bind command to map “Ctrl+t” to execute the pwd command:

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

After this command is executed, we press ...