linux shell zsh,Linux终极shell Z Shell 用强大的zsh oh-my-zsh把Bash换掉
Bash確實是不錯的Shell,但仍有用不少不盡人意的地方,如自動補全的功能不夠強大,定位較長路徑不夠方便,命令歷史管理不夠完善等。javascript
介紹使用zsh,功能十分強大…推薦給你們!java
1 介紹zsh
1.1 Linux shell
經常使用的Shell有這么幾種,sh、bash、csh等,想知道你的系統有幾種shell,能夠經過如下命令查看:linux
cat /etc/shells
未安裝zsh,顯示結果以下:
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/cshgit
1.2 zsh簡介
Zsh是一個Linux下強大的shell, 因為大多數Linux產品安裝,以及默認使用bash shell, 可是絲絕不影響極客們對zsh的熱衷, 幾乎每一款Linux產品都包含有zsh,一般能夠用apt-get、urpmi或yum等包管理器進行安裝github
Zsh具備如下主要功能
開箱即用、可編程的命令行補全功能能夠幫助用戶輸入各類參數以及選項
在用戶啟動的全部shell中共享命令歷史
經過擴展的文件通配符,能夠不利用外部命令達到find命令通常展開文件名
改進的變量與數組處理
在緩沖區中編輯多行命令
多種兼容模式,例如使用/bin/sh運行時能夠假裝成Bourne shell
能夠定制呈現形式的提示符;包括在屏幕右端顯示信息,并在鍵入長命令時自動隱藏
可加載的模塊,提供其余各類支持:完整的TCP與Unix域套接字控制,FTP客戶端與擴充過的數學函數
徹底可定制化web
1.3 zsh與oh-my-zsh終極配置
以前是由于看到這篇文章:終極Shell——Zsh 才選擇使用zsh,被它的自動完成、補全功能吸引了。shell
這也是“工欲善其事,必先利其器”系列文章。vim
選擇oh-my-zsh, oh-my-zsh是基于zsh的功能作了一個擴展,方便的插件管理、主題自定義,以及漂亮的自動完成效果。數組
在Github上找關于zsh的項目時發現的,試用了一下以為很方便,不用像上面文章里面提到的那么復雜,配置一些插件的名稱便可使用相應的功能。
2 安裝zsh
2.1 安裝zsh
對于通常的Ubuntu系統,配置好正確的源以后,就能直接鍵入如下命令安裝:
sudo apt-get install zsh
對于linux系統,直接使用如下命令安裝:
yum -y install zsh
2.2 配置zsh
把.zshrc拷貝到相應用戶的home目錄便可
(也能夠把你的bash的配置文件(/.bash_prorile或者/.profile等)給拷貝到zsh的配置文件~/.zshrc里,由于zsh兼容bash)
使用 Zsh 擴展集合:oh-my-zsh
oh-my-zsh 幫咱們整理了一些經常使用的 Zsh 擴展功能和主題:https://github.com/robbyrussell/oh-my-zsh
咱們無需本身去搗搞 Zsh,直接用 oh-my-zsh 就足夠了,若是你想繼續深造的話那再去弄。
先安裝 git:sudo yum install -y git
安裝 oh-my-zsh(這個過程可能會有點慢,或者須要重試幾回):wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh
安裝效果圖以下:
在以 root 用戶為前提下,oh-my-zsh 的安裝目錄:/root/.oh-my-zsh
在以 root 用戶為前提下,Zsh 的配置文件位置:/root/.zshrc
為 root 用戶設置 zsh 為系統默認 shell:chsh -s /bin/zsh root
若是你要從新恢復到 bash:chsh -s /bin/bash root
如今你關掉終端或是從新連上 shell,如今開頭是一個箭頭了,以下圖:
如今zsh和oh-my-zsh都安裝好了,如今重點講下zsh的配置!
建立~/.zshrc配置文件,先給看下個人配置,能夠憑本身喜愛更改:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/amoscykl/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
# zhs的主題
ZSH_THEME="ys"
# Set list of themes to load
# Setting this variable when ZSH_THEME=random
# cause zsh load theme from this variable instead of
# looking in ~/.oh-my-zsh/themes/
# An empty array have no effect
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# z命令快速跳轉目錄 x命令解壓一切文件 命令行能夠直接google
plugins=(
git z zsh-autosuggestions extract web-search zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
#
保存并執行命令,使配置生效:
cd ~ && source .zshrc
總結
以上是生活随笔為你收集整理的linux shell zsh,Linux终极shell Z Shell 用强大的zsh oh-my-zsh把Bash换掉的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 消息称特斯拉 Model Y 国内将再次
- 下一篇: 多款中端新机将亮相,消息称华为 nova