Zsh and bash are shell scripts that can run in Linux. The default is bash. To use Zsh, you need to install it separately. The following small series will be for Zsh in Linux. Installation and configuration for everyone to make a detailed introduction, interested friends can come to understand.
1. Install
mounted zsh
zsh mounted in Gentoo, we need to install app-shells /zsh (zsh itself) and emerge through app- Shells/zsh-completion (zsh completion script) two packages.
Code Listing 1.1: Installing zsh via emerge
# emerge zsh zsh-completion
Entering zsh
When you first run zsh, you Will get some information as follows. Because we will create an init file later, so you can skip this one function menu.
Code Listing 1.2: Skip initial configuration
$ zsh
This is the Z Shell configuration function for new users, zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~). This function can help you with a few settings that should
make your use of the shell easier.
You can:
(q) Quit and do nothing. The function Will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment.
That will prevent this function being run again.
(1) Continue to the main menu.
--- Type one of the keys in parentheses --- q
2. Configuration
Introduction
Running zsh will start zsh for a session. If you want a permanent solution, please refer to the chapter on saving settings. After the installation is complete, zsh may seem very simple and very limited in functionality. In order to change this situation, you need to modify several configurations.
Advanced Tab Completion
You need to run the following command to enable zsh's tab completion system:
Code 2.1: Open Completion System
% autoload -U compinit
% compinit
The default completion style is very normal and simple. If you want to improve its appearance, run the following command:
Code 2.2: Improve completion style
% zstyle ‘:completion:*:descriptions’ format ‘%U%B %d%b%u’
% zstyle ‘:completion:*:warnings’ format ‘%BSorry, no matches for: %d%b’
Command Error Correction
It is also a good idea to enable the command automatic error correction function:
Code 2.3: Turn on error correction function
% setopt correctall
prompt
< The current prompt may seem boring, but we can fix it in a few simple steps. First, we need to initialize the advanced command prompt support:
Code 2.4: Turn on the advanced command prompt function
% autoload -U promptinit
% promptinit
We can use the prompt -p command to list the available prompt samples. Now we can activate one we like:
Code 2.5: Select a prompt sample
(Use the prompt of your choice instead of “gentoo”)
% Prompt gentoo
Note: If you are trying a different prompt and you don't want to see an example of each prompt, then you can use prompt -l to list the available prompts.
Another option is to create your own prompt. You need to set the PS1 environment variable to implement this idea.
Code Listing 2.6: A simple custom prompt
% export PS1=“[Test Prompt] 》 ”
[Test Prompt] 》
It's great to be able to create custom text prompts, while zsh also provides a number of escape sequences to allow you to insert system information into the prompt. Some of the available escape sequences are as follows:
Escape sequence print effect
%T system time (hour: minute)
%* system time (hour: minute: second) )
%DSystem Date (Year-Month-Day)
%nYour Username
%B - %b Start to End Use Bold Print
>
%U - %u starts to end with underline printing
%d your current working directory
%~ Relative path of your current working directory relative to ~
Hostname of %M computer
%m of computer's hostname (truncate before the first period)
%lYour current tty
You only need Inserting these escape sequences into the environment variable PS1 will do so, and zsh will automatically parse them.
Code Listing 2.7: A more complicated prompt
% export PS1=“[%* - %D] %d %% ”
[08:44 :23 - 06-02-18] /home/username %
Previous12Next page Total 2 pages
When doing a Java website project, if you encounter a problem that the Tomcat serve
In Linux system, Apache and Tomcat are both mainstream Web servers. So, is there any relationship be
If you dont embed a font when you create a PDF file, it may cause different styles
In Linux system operation, if you need to delete a file in swap for some reason, wh
How to undo operations in Git in Linux
How does Centos build CDN server through nginx reverse proxy and proxy_cache cache
Ubuntu install Nox, compile make error, what should I do?
How to restart Tomcat regularly on Linux system
Limit the operation example of IP login shell after Linux user exits the system
What can I do if I cannot mount NTFS after installing Ubuntu?
Linux uses xfs when there is no disk space. How to deal with
Linux grub2 startup failure solution
How to install and use Glances in Linux
Windows7 system configuration ipv6 protocol need to pay attention to what?
Win10 system Edge browser download file garbled how to solve
Why win10 play lol blue screen flash back very card
Windows 8 system to retrieve desktop icons
CPU overclocking caused computer blue screen solution
Windows XP user account blank solution
Solve the win8 system.exe program disk takes up 100% of the tutorial
When watching video, how to do up and down split screen
Win7 system computer monitor flashing and flashing black screen failure reasons and solutions