Linux bash shortcuts are something that many friends who are used to using shortcuts want to know, but there are not many articles about shortcuts on the Internet, note that Linux bash has different effects. You must pay attention to the bash version and the Linux bash shortcut keys.
I always wanted to execute some operations by pressing a key like in the VI editor through Bash. It was a chance to find that stty could be implemented.
First read the script:
#! /Bin/sh
# We can use this script to automatically detect keys. As for what it is used for, if you are benevolent, then the wise may see wisdom. "A hero must be useful ".
#13:00:54 update
# Wangxiaoyu (AT) live.com From http://wangxiaoyu.blog.51cto.com
_ Tty_setting = $ (stty-g)
Stty-icanon
Stty-echo
# We can use c2 arguement to use keyboard shortcut cut with 2 characters.
_ Key_press = $ (head-c1)
Stty $ _ tty_setting
# The following section describes how to judge the input.
#
Case $ _ key_press in
A) echo-en "here we can replace it with the command string we want to execute 1 \ n"
;;
2) echo-en "here we can replace it with the command string we want to execute 2 \ n"
;;
3) echo-en "here we can replace it with the command string we want to execute 3 \ n"
;;
4) echo-en "here we can replace it with the command string we want to execute 4 \ n"
;;
5) echo-en "here we can replace it with the command string we want to execute 5 \ n"
;;
6) echo-en "here we can replace it with the command string we want to execute 6 \ n"
Exit 1 ;;
*) Echo-en "here we can replace it with the script help information-related command \ n"
Esac
Note:
Stty is used to display and modify terminal settings. This complex command can be used in scripts to control terminal behavior or display output methods. Combined with special characters and case or other conditions, we can easily search files by pressing Ctrol + F.
Script. Stty-g is used to record stty parameters. After the terminal is modified, it is restored in time after use.
Stty-echo is commonly used to require users to enter passwords.
The Linux bash shortcut in the bash version should be mentioned here first.
- Linux shell script BASICS (1)
- A Brief Introduction to how to obtain the file path of a Linux Process
- Detailed analysis of Linux Server Memory
- Security Configuration for Linux system security improvement
- Ten common linux management errors