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 Terminal Command to improve work efficiency in unix system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to use terminal commands to improve work efficiency in unix system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use terminal commands to improve work efficiency in the unix system.

Search in reverse in the terminal

Reverse search is one of the best features on Unix systems.

Suppose you forget the complete command and only remember some of it, you can type the part you remember to do a reverse search. Let's look at an example:

I want to restart the server running in the staging environment, but I only remember the staging keywords and forget the other commands. At this point, you can enter reverse search mode by typing ctrl + r and enter:

(reverse-i-search) `stag': cd / home/ubuntu/server; pm2 stopapp.js & & export NODE_ENV= "staging" & & pm2 startapp.js & & pm2 logs

It remembers the commands you typed before and matches what you want to find now.

Create an alias for the command

Aliases (Alias) will become one of the most powerful tools in the hands of every programmer because it allows us to write our own shortcuts. Let's look at an example.

Alias dev = "cd~/ Project / development"

This command will be run after typing dev and pressing Enter. This feature is useful when you want to navigate to another folder. Almost all commands can be run under aliases. The most common commands are as follows:

Alias..= "cd..." Alias gs= "git status" alias gp= "git pull" alias gb= "git branch" alias ga= "git add."

As you can see, creating aliases saves a lot of time, and I create directories for these aliases, so you don't have to type cd.. every time you run the command Wait. You can feel the convenience of creating aliases without a detailed explanation here.

In addition, you can use parameters such as $1 and $2 to improve scalability, such as:

Aliasgc = "git commit-m $1"

Now, just type gc "Commit message" to commit the change information. To sum up, you only need to create aliases for the most commonly used commands and make them shorter to improve productivity.

Now that we know the use of aliases, let's see how to set them. There are two ways: the first is to set up a temporary alias, where you can run the following command:

Aliasdev = "cd~/Project / development"

The temporary alias continues until the session is closed. Another way is to set a permanent alias. To do this, you need to set it in shell, and I'm using Zsh, so update the ~ / .zshrc file.

If you are using Bash, use the ~ / .bashrc file. Add the command to the file, which should look like this:

Zshrc file

After making changes to the file, you need to run the following command:

Source / .zshrc

Then, all aliases created can run permanently.

Use pbcopy

You can run this command on Mac, but if you want to run it on a Linux distribution, you need to follow this guide.

Pbcopy is similar to copy on steroids (a plug-in that allows you to copy highlighted text to the clipboard). You can use this command to copy the contents of the file to the clipboard. For example: suppose you have to copy the SSH (secure Shell Protocol) identity to the clipboard, use the following command:

Pbcopy

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

Development

Wechat

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

12
Report