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 configure a concise and efficient Zsh for linux

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

Share

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

Editor to share with you how to configure a concise and efficient Zsh linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Install Zsh

My laptop uses ArchLinux and the server uses Ubuntu. This paper mainly introduces the configuration methods of these two distributions. Please try the Red Hat release version by yourself.

Personally, I like to install it from the source of the distribution as much as possible. Installation from the source has the advantages of convenience, stability and easy maintenance.

Install Zsh in ArchLinux

Enter in the terminal:

Sudo pacman-Sy zsh installs Zsh in Ubuntu

Enter in the terminal:

Sudo apt-get updatesudo apt-get install zsh install plug-in

All I need is two plug-ins:

Zsh-autosuggestions: this is an automatic suggestion plugin that automatically prompts you for the commands you need.

Zsh-syntax-highlighting: this is a code highlighting plug-in that makes your command line commands clear and clear.

There is another theme:

The zsh-theme-powerlevel10k theme provides a beautiful prompt that shows the current path, time, success of the command execution, support for git branch display, and so on.

Also install it from the source as much as possible.

The source of Ubuntu 20.10 is powerlevel9k, and the actual experience after configuration is not much different from that of powerlevel10k.

Install plug-ins and themes in ArchLinux

Enter the command in the terminal:

Sudo pacman-S zsh-autosuggestions zsh-syntax-highlighting zsh-theme-powerlevel10k zsh-completions installs plug-ins and themes in Ubuntu

Enter the command in the terminal:

Sudo apt-get install zsh-autosuggestions zsh-syntax-highlighting zsh-theme-powerlevel9k

In this way, plug-ins and themes are installed.

Change the default shell and configure plug-ins and themes

Once installed, Zsh is enabled and plug-ins and themes are configured.

Change the default shell

Terminal input command:

Chsh-s / usr/bin/zsh

ArchLinux and Ubuntu both do the same thing, and then log out and log back in, and Zsh is enabled. A configuration interface automatically appears when you enter Zsh for the first time, which can customize Zsh as needed.

Enter 1 here to enter the configuration interface.

The meaning of each menu in the configuration interface is:

1: set options related to command history

2: set up the command completion system

3: set up hot construction

4: to select a variety of common options, just select "On" or "Off"

0: exit and use a blank (default) configuration

A: terminate the setting and exit

Q: exit

Here, follow the tips, and then configure it according to your own preferences. Once configured, a .zshrc file will be generated in your user directory. Then we are going to enable plug-ins and themes in this file.

Configure plug-ins and themes

The configuration file for Zsh is ~ / .zshrc file, which is in your user directory ~ /. Delete this file and enter Zsh again, which will trigger the configuration interface of Zsh.

Enable plug-ins and themes in ArchLinux

Open the ~ / .zshrc file and add the following line of code to it:

Source / usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zshsource / usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zshsource / usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme enables plug-ins and themes in Ubuntu

Open the ~ / .zshrc file and add the following line of code to it:

Source / usr/share/powerlevel9k/powerlevel9k.zsh-themesource / usr/share/zsh-autosuggestions/zsh-autosuggestions.zshsource / usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

In this way, plug-ins and themes are successfully enabled, plug-ins are easy to use without additional configuration, and those with additional configuration requirements can study on their own.

When the powerlevel10k theme is entered for the first time, it triggers a configuration interface.

Then follow the prompts and your preferences to complete the configuration step by step.

Here you can choose the prompt you like.

After the configuration is completed, you can use it happily!

These are all the contents of the article "how to configure a concise and efficient Zsh for linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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