- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create key binds in the Linux system using the terminal?
To set Readline key bindings and variables in the Linux system, we use the bind command.
The bind is used to assign functions and macros to a key. It allows to create hotkeys instead of typing the entire command. The bind command available in the shell built-in command.
The syntax of the bind command is as follows.
bind [-lpsvPSVX] [-m KEYMAP] [-f FILENAME] [-q NAME] [-u NAME] [-r KEYSEQ] [-x KEYSEQ:shell-command]
The general syntax of the bind command seems so complicated, but the bind command is simple to use and we can easily create macros.
Brief description of options available in the bind command.
|Sr.No.||Option & Description|
Display the list names of functions
Display the list names of functions and bindings
Display list functions and bindings in a form that can be reused as input
Display the list of key sequences that invoke macros and their values in a form that can be reused as input
Display variable names and values
Display variable names and values in a form that can be reused as input
Query about which keys invoke the named functions
Remove the binding for KEYSEQ
Read key bindings form FILENAME
Displays a help message and then exits.
It gives info about the version and then exits.
To list all the readline functions names, we use -l option with the bind command in the Linux system as shown below.
$ bind -l
To list the keybindings and the corresponding function names, we use -p option with the bind command in the Linux system as shown below.
$ bind -p
Here, we will create a custom key bind in the Linux system. To pint “Hey, welcome to tutorialspoint!” we will use CTRL + v to print this message on the terminal.
$ bind ‘” \C-v”:” Hey, Welcome to tutorialspoint!”’
After executing the above command, a new custom key bind will be created. To print “Hey, welcome to tutorialspoint!” just have to enter CTRL + v instead of typing the whole message. To list the all-custom key bindings, we use the -x option with the bind command as shown below
$ bind -x
To remove an existing key binding in the Linux system, we use -r option with the bind command as shown below
$ bind -r “\C-v”
To display more information about the bind command, we use the --help option with the bind command as shown below.
$ bind --help
- How to Create a File in the Linux/Unix system using terminal?
- How to create a new directory in Linux using the terminal?
- How to remove files and directories in the Linux operating system using the terminal?\n
- How to decorate your Linux Terminal using Shell?
- How to create an Animated Art on Your Linux Terminal?
- How to check total space and available space in Linux using the terminal?
- Formatted text in Linux Terminal using Python
- How to use rainbow colors in linux terminal
- How to flushes file system buffers in the Linux operating system?
- How to move jobs to the background in the Linux system?
- How to do simple Arithmetic on Linux Terminal?
- How to Create a New Ext4 File System in Linux?
- How to Find Linux Server Geographic Location in Terminal?
- How to display the current working directory in the Linux system?
- How to converts tabs to spaces in the Linux system?