Linux bash shortcut keys

Source: Internet
Author: User

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.

  1. Linux shell script BASICS (1)
  2. A Brief Introduction to how to obtain the file path of a Linux Process
  3. Detailed analysis of Linux Server Memory
  4. Security Configuration for Linux system security improvement
  5. Ten common linux management errors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.