Oh-my-zsh Configure your zsh to increase the ultimate choice of shell-driven lattice

Source: Internet
Author: User

Sorry, this post has been postponed, people are lazy ... Look at this shiny headline and forgive me!

Why is this article classified under a Mac? The first question, which we will explain later.

What is ZSH? A second question ...

Should you touch a little bit of a shell or know a little bit?

If you do not know the shell, then click on the ads to leave, life is short, time is precious.

In the Unix kernel of the operating system, of course, now derive a lot of branches, Linux, OS X count.

Even if the shell is a bridge to the above system kernel directives, we enter a symbolic identifier (shell command) that is easy to remember and identify with the keyboard.

The shell then parses the command and then feeds back to the kernel to perform a series of operations.

So the question is, what does the zsh and the shell have to say today?

In fact, Zsh is also a shell, but not our system default shell, Unix derivative system of the default shell is bash

In the case of Mac, let's take a look at a few shells built into the system

? /users/zhangzhi >cat/etc/shells# List of acceptable shells for chpass (1). # Ftpd won't allow Users to connect who a Re not using# one of these shells./bin/bash/bin/csh/bin/ksh/bin/sh/bin/tcsh/bin/zsh

6 kinds

If it's a Linux system, you want to use zsh, you need to install it yourself, so today this blog post is classified into the Mac system. Here, the first 2 small questions are answered.

All of the following actions take the Mac as an example:

The Mac is preloaded with zsh, but few people switch directly to use this shell, because the default configuration of zsh and its complicated, daunting, until oh-my-zsh this open source project, let the zsh configuration down to 0 threshold. And it's completely compatible with bash.

Oh-my-zsh Address: Https://github.com/robbyrussell/oh-my-zsh

It was born for me to configure your zsh.

How to use Zsh

If it's a Linux system, first you need to install Zsh

sudo yum install zsh or sudo apt-get install zsh

We don't need to install the MAC system.

Next we need to download the OH-MY-ZSH project to help us configure zsh

wget Automatic Installation

wget Https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh-O-| Sh

When you install OH-MY-ZSH, it automatically reads your environment variables and automatically sets them up for zsh.

So the zsh is basically configured to complete, you need a line of command to switch to ZSH mode.

Chsh-s/usr/local/bin/zsh

How to customize the zsh configuration

At present, the configuration of zsh is only to support the configuration of oh-my-zsh to do a little bit of change, not particularly in-depth understanding.

It's like a DIY pc, and you need all the tough parts to be assembled together to get the most out of it.

For example, you use a good CPU and graphics card, the lack of choice of 128M of old memory, it is really tragic

After the oh-my-zsh is installed, it is configured in the user directory under the. Oh-my-zsh Directory

The zsh configuration file is also in the user directory. ZSHRC hidden files

Editing a configuration file

Nano. ZSHRC

Each line has a # number in front of it, and if you want the configuration to take effect, remove the #号即可. Here are just a few of the possible uses, most of which I haven't figured out yet.

Zsh_theme= "Robbyrussell"//is used to specify the ZSH style, just like the one above me.

If your terminal uses ITERM2, then this style of skin settings please click to view another blog post

I used the Robbyrusell skin, the corresponding skin directory in. Oh-my-zsh/themes/robbyrussell You can also edit your skin template file to reach the shell style you want.

Disable_auto_update= "true"//whether Automatic Updates

lugins= (git autojump OSX brew node NPM)//zsh plug-in used

Plug-ins can make your zsh more powerful. Look at the following example:

The above zsh from the red arrow indicates the zsh start position, followed by the absolute path, followed by the display git (dev) x is the above meaning?

Git means that this directory is hosted by a git repository.

(Dev) represents the current directory where the Git branch is the dev

X indicates that there is a change in the contents of the current file and is not submitted to the code base, and if it is submitted, it will become a green √ number.

The above series of features about Git is that I opened the Git plugin in zsh (this plugin is a plugin that comes with the OH-MY-ZSH project and is enabled by default)

In addition, the above figure also has a function, is automatic completion

The above whenever I enter a letter, corresponding to the following will be in a timely manner to complete the shell instructions, directory name or file name, very smart (note, not the completion of the TAB key, is fully automatic) This feature is of course dependent on another plug-in, I intend to open a separate blog.

In addition, the above diagram reveals another powerful feature of Zsh:

Alias settings

Let's look at the alias settings for git in the git plugin:

? /users/zhangzhi >nano. oh-my-zsh/plugins/git/git.plugin.zsh

Look at the Alias setting Content section:

Alias g= ' git ' Alias ga= ' git add ' Alias gaa= ' git add--all ' Alias gapa= ' git add--patch ' Alias gb= ' git branch ' alias gba= ' git BR Anch-a ' Alias gbda= ' git branch--merged | Command Grep-ve "^ (\*|\s*master\s*$)" | Command xargs-n 1 git branch-d ' Alias gbl= ' git blame-b-W ' Alias gbnm= ' git branch--no-merged ' Alias gbr= ' git branch--rem Ote ' Alias gbs= ' git bisect ' alias gbsb= ' git bisect bad ' alias gbsg= ' git bisect good ' alias gbsr= ' git bisect reset ' Alias gbss= ' git bisect start '

Alias g= ' git '

means to define an alias G to replace the git command in the shell

For example, the GST I used above is an alias, and all of its shells are git status

Using aliases is not a lot of input, and completely you have to follow your memory habits to set their own shell instructions, too powerful.

Oh-my-zsh Configure your zsh to increase the ultimate choice of shell-driven lattice

More specific configuration and plug-ins I am also in constant research and discovery, look forward to the time to share with you!

Oh-my-zsh Configure your zsh to increase the ultimate choice of shell-driven lattice

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.