Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use bash Shortcut in Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use bash shortcuts in Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Always wanted to implement through Bash, as in the VI editor, press a key to perform some kind of operation, a chance to find that stty can be achieved.

Please look at the script first:

#! / bin/sh

# We can use this script to automatically detect keystrokes. As for what it is used for, people have different opinions, and wise people have their own wisdom. "Heroes must have the opportunity to show their talents."

# 2009-12-29 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 with 2 characters.

_ key_press=$ (head-C1)

Stty $_ tty_setting

# here is the part to judge the input

#

Case $_ key_press in

A) echo-en "We can replace it here with the command string we want to execute 1\ n"

2) echo-en "We can replace it here with the command string we want to execute 2\ n"

3) echo-en "We can replace it here with the command string 3\ n that we want to execute"

4) echo-en "We can replace it here with the command string 4\ n that we want to execute"

5) echo-en "We can replace it here with the command string we want to execute 5\ n"

6) echo-en "We can replace it here with the command string 6\ n that we want to execute"

Exit 1

*) echo-en "here can be replaced with commands related to the help information of the script\ n"

Esac

Note:

Stty is used to display and modify terminal settings, this complex command can be used in scripts to control the behavior of the terminal or the method of displaying output. Combined with special characters and case or other conditions, we can easily search for files like pressing Ctrol + F.

In the script. Stty-g is used to record the parameters of stty, which can be restored in time after the terminal is modified.

Among them, stty-echo is very common and is often used to require users to enter passwords.

This is the end of this article on "how to use bash shortcuts in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report