2

Summarize

Zsh has a mature ecology, modern syntax, and powerful functions, and is currently the best choice for shells.

what do i do with the shell

I am a heavy user of the shell, and all development work is done under the shell except for writing documentation. So the shell is my productivity tool. Creating an efficient shell environment can greatly improve my work efficiency. There are many functions, such as file opening and closing, file directory jumping, initial configuration, and eda tool settings, which are not suitable for writing in other scripting languages, and shell scripts are also the best option. Many sub-functions are suitable for being compiled into binary files, and then controlled by the shell to uniformly call.

Therefore, the choice of shell is very concerned about its ecology and the existing functions in the ecology. If the ecology is not good, you need to build your own wheels, which shows that it is not suitable for IC developers like me, so I choose to eliminate the most commonly used csh in our industry. Secondly, it is best to have a complete set of environments that can be used directly, so that there is no need for It takes a lot of time to configure it into a convenient environment. In this regard, the existence of oh-my-zsh greatly reduces the configuration time of users. Bringing doctrine is very cool. There are many built-in themes and plugins, which can be used directly.

worry

In our industry, many people use csh, and some scripts may be written in csh. They feel that it is very inconvenient to transfer, which is equivalent to someone else already having a csh ecology. If you transfer it alone, it is equivalent to abandoning the ecology.
In my opinion, this is not a problem at all, because if the so-called script of others is a very rigorous script, it will not depend on SHELL. If it depends on SHELL, then the script must be more random, or some variable settings and source The path is set. If you want to reuse it, you can use the tool to automatically convert it to bash (so that zsh can also be used). This is a one-time workload.
Compared with the efficiency improvement brought by zsh, this cost is small.
To be quiet, I don't actually use other people's csh scripts, because their scripts are really just some variable settings and aliases for their own use. I can't use it.

Let me introduce its advantages one by one.

compatibility

Zsh is basically compatible with bash, so most bash scripts can be used directly.
See this article of mine for the nuances

file completion

As long as the tab key is pressed, it can list files or directories according to the previous command.
If it is svn add , it will only list files that were not added to the repository.
If it is cd , it will only list the directory.

Convenient directory switching

You can use cd ..... up 5 layers, you can use d Enter the last 5 directories, and then use numbers to choose which directory to enter, you can use cd /v/o/s/d /var/opt/synopsys/doc enter-- /var/opt/synopsys/doc directory
图片.png

command option completion

This is a type of completion, but its power is worth mentioning again that it can command ideas. for example
dconf <Tab>
will automatically list subcommands

 $ dconf <Tab>
compile  -- compile a binary database from keyfiles
dump     -- dump an entire subpath to stdout
help     -- display help information
list     -- list the contents of a directory
load     -- populate a subpath from stdin
read     -- read the value of a key
reset    -- reset the value of a key or directory
update   -- update the system databases
watch    -- watch a path for changes
write    -- change the value of a key

command parameter completion

For example, after typing the above command dconf read / press <Tab>, it will automatically output org/ and system two options

 $ dconf read /
org/     system/

For another example, enter kill vim and press tab. If there is only one match, it will automatically become kill 5378 , and the multiple will be as follows:
图片.png

history record

The history of zsh is shared among multiple terminals, you can use the up arrow to search, for example, enter make and then use the up key, it will list the commands that used make switch in turn, which is very important in the implementation work. Efficient.

oh-my-zsh

150kStar, 275+ plugins, 140+ themes, 2000+ contributors..., from this set of numbers, we know how good a shell tool this is.

The existence of oh-my-zsh greatly simplifies the configuration and use of zsh, which is equivalent to direct check-in in a hardcover room.

Various themes can be successfully installed as long as they are written in the configuration file, and various plug-ins can be installed successfully as long as they are added to the configuration file.

We won't talk much about this, you can use it directly if you are interested.

Additional plugins

There are some enhanced plugins under https://github.com/zsh-users , all of them are very commands, especially recommended zsh-autosuggestions , it can automatically list the commands and options you have entered before, such as using the above The dconf command as an example
图片.png

file type sensitive alias

For example, the configuration is as follows:

 alias -s tgz='tar -zxvf'
alias -s gz='tar -zxvf'
alias -s bz2='tar -jxvf'
alias -s zip='unzip'
alias -s v=vi
alias -s sv=vi
alias -s vhdl=vi
alias -s cpp=vi

Entering test.sv under zsh will automatically open it with vi, enter test.tgz, it will be executed with tar -zxvf test.tgz


harriszh
338 声望131 粉丝

做些有趣的事,留些有用的存在