This article was first published at szhshp.org/tech/2017/0…

Reprint please specify

Update history:

  • May 28, 2017
    • Save the initial text
  • July 09, 2017
    • Adding plug-ins

Zsh

At present, the default Shell of the commonly used Linux system and OS X system is Bash, but the truly powerful Shell is the hidden ZSH, which is definitely the sports car in the carriage, the flying car in the sports car, known as the “ultimate Shell” in history, but due to the configuration is too complicated, so no one cares about it at the early stage. A lot of people come up to the ZSH configuration guide and just walk away without saying anything. Until one day, a his boringness programmers developed abroad a quick-and-dirty ZSH project, called “oh my ZSH”, making the website is: https://github.com/robbyrussell/oh-my-zsh. It’s like the “X days will teach you C++” series, and it’s real.

Install ZSH and OH-my-zsh

sudo apt-get install zsh git wget
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
chsh -s /bin/zsh
reset

use

First, use this command to see what Shell is currently in use

echo $SHELL

Set Zsh as the default Shell

Normally, run the following code:

chsh -s /bin/zsh

However, there are many things that can happen here, such as insufficient permissions, or the path is not /bin/zsh. In this case, look at all the shells first

cat /etc/shells

Then set ZSH that to the corresponding shell

chsh -s [which zsh]

However, the CHSH: PAM authentication failed error may occur

So use this method:

well, my solution maybe help you

sudo vim /etc/pam.d/chsh

then, comment auth required pam_shells.so

sudo chsh [user] -s [which zsh]

Sudo vi /etc/passwd file

Open /etc/passwd:

sudo vi /etc/passwd Find the line with your username:

username:x:1634231:100:Your Name:/home/username:/bin/bash and replace bash with zsh:

username:x:1634231:100:Your Name:/home/username:/bin/zsh Log out and log in back for the changes to take effect.

Theme Settings

To set the theme, use oh-my-zsh

vi ~/.zshrc

Open configuration, then set, and use the theme folder under oh-my-zsh

ZSH_THEME=robbyrussell

The alias set

Add a separate name to the verbose command line, and set it at the end of the configuration file:

# Example aliases
# alias zshconfig="gedit ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias cls='clear'
alias show='nautilus'

Uncomment the first line and you can quickly open the configuration file via zshconfig

The plugin Settings

Oh-my-zsh project provides a complete system of plugins. By default, more than 100 plugins are provided in ~/. Oh-my-zsh /plugins, which can be used according to your actual learning and working environment. Just open the ZSH file in the relevant directory and take a look.

ZSHRC plugins are also configured in.zshrc. If you find the plugins keyword, you can load your own plugins. Git is loaded by default.

plugins=(git textmate ruby autojump osx mvn gradle)
autojump
installation

First install autojump:

sudo apt install autojump
Copy the code

Finally add the following code. ZSHRC (git is the default plug-in) :

  plugins=(git autojump)

Then add at the very end:

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

You may need to perform a Reload or Log Off on the terminal to see the change

That will do

use

The main one is the j command:

j [name]

Autojump first looks for the access weight of the path containing the top keyword and then goes to the folder with the highest weight, requiring you to enter that folder first

This can be done by typing:

j --stat

View the weights of each folder visited

Git

A default plug-in that automatically displays Git information in the repo

Ubuntu

These are just aliases

There are some useful aliases:

ag = sudo Apt-Get agi = sudo Apt-Get Install agd = sudo Apt-Get Dselect-upgrade By now you already can guess almost all aliases

series

Play with Linux gracefully

reference

  • The ultimate Shell – ZSH
  • chsh: PAM authentication failed
  • Can’t make ZSH the default shell