目錄
一搬卒、zsh說明
zsh是一個(gè)Linux下強(qiáng)大的shell, 由于大多數(shù)Linux產(chǎn)品安裝以及默認(rèn)使用bash shell, 但是絲毫不影響極客們對zsh的熱衷, 幾乎每一款Linux產(chǎn)品都包含有zsh,通吃泊妫可以用apt-get抵乓、urpmi或yum等包管理器進(jìn)行安裝.
zsh是bash的增強(qiáng)版伴挚,其實(shí)zsh和bash是兩個(gè)不同的概念靶衍,zsh更加強(qiáng)大。
通常zsh配置起來非常麻煩茎芋,且相當(dāng)?shù)膹?fù)雜颅眶,所以oh-my-zsh是為了簡化zsh的配置而開發(fā)的,因此oh-my-zsh算是zsh的配置.
Ubuntu16.0.4_Server_64_no_au_zsh
說明:
- 這是我通過VM15導(dǎo)出已配置了zsh和root遠(yuǎn)程連接的Ubuntu16.0.4服務(wù)器版的vof包
- 地址:https://pan.baidu.com/s/1MH4FhnxHDI3b4PIMWfiiFg
bgnq
參閱:oh-my-zsh
二田弥、準(zhǔn)備
- 查看系統(tǒng)當(dāng)前使用的shell
echo $SHELL
- 查看系統(tǒng)自帶哪些shell
cat /etc/shells
- oh-my-sh相關(guān)文件位置
vim ~/.zshrc
說明:
~
表示用戶名目錄涛酗,<.FileName>
表示隱藏文件.
三、安裝zsh
1. 開始安裝
apt install zsh -y
提示:
- 查看系統(tǒng)自帶哪些shell
cat /etc/shells
表明已經(jīng)安裝好zsh.
2. 配置
- zsh設(shè)為默認(rèn)shell
chsh -s /bin/zsh
reboot
提示:
- 若總是報(bào)錯(cuò)
chsh: PAM: Authentication failure
直接修改用戶的配置
vim /etc/passwd/
- 查看系統(tǒng)當(dāng)前使用的shell
echo $SHELL
表明已經(jīng)將zsh設(shè)置為默認(rèn)shell.
- 待解決問題: 不知道為什么我的root賬戶的用戶名怎么變成了ubuntu偷厦?
四商叹、安裝oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
或
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
五、個(gè)性化
1. 主題
vim ~/.zshrc
source ~/.zshrc
參閱:oh-my-zsh主題只泼、更多主題
我比較喜歡
AgnosterZak
Xterm配色方案:紅- 綠 -藍(lán): 16 61 73
安裝
cd ~/.oh-my-zsh/themes
wget https://raw.githubusercontent.com/zakaziko99/agnosterzak-ohmyzsh-theme/master/agnosterzak.zsh-theme
vi ~/.zshrc
agnosterzak
source ~/.zshrc
apt install fonts-powerline -y
注意:
如果
ZSH_THEME=""
則不啟用任何主題.如果
ZSH_THEME="random"
,那么每次打開一個(gè)新的終端窗口時(shí)剖笙,電腦會隨機(jī)選擇一個(gè)主題使用,
echo $RANDOM_THEME
可輸出當(dāng)前主題名稱.如果你想從你最喜歡的主題列表中選擇隨機(jī)主題辜妓,那么
ZSH_THEME="random"
且
ZSH_THEME_RANDOM_CANDIDATES的值設(shè)置為你喜歡的主題名稱
例如:
ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
2. 插件
- 安裝incr自動(dòng)補(bǔ)全插件
推薦
cd ~/.oh-my-zsh/plugins/
mkdir incr && cd incr
wget http://mimosa-pudica.net/src/incr-0.2.zsh
vi ~/.zshrc
source ~/.oh-my-zsh/plugins/incr/incr*.zsh
source ~/.zshrc
提示:
- 與vim的提示相沖突的解決方案
$ vim t _arguments:451: _vim_files: function definition file not found
將~/.zcompdump*刪除即可
rm -rf ~/.zcompdump*
exec zsh
- 直接使用的插件
推薦
vi ~/.zshrc
plugins=(git extract z)
source ~/.zshrc
- git
默認(rèn)開啟的插件枯途,提供了大量 git 的alias.
- extract
功能強(qiáng)大的解壓插件忌怎,所有類型的文件解壓一個(gè)命令x全搞定籍滴,再也不需要去記tar后面到底是哪幾個(gè)參數(shù)了.
- z
強(qiáng)大的目錄自動(dòng)跳轉(zhuǎn)命令,會記憶你曾經(jīng)進(jìn)入過的目錄榴啸,用模糊匹配快速進(jìn)入你想要的目錄.
- 安裝autojump自動(dòng)跳轉(zhuǎn)插件
apt install autojump
vi ~/.zshrc
. /usr/share/autojump/autojump.sh
source ~/.zshrc
提示:
- 安裝zsh-syntax-highlighting語法高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
source ~/.zshrc
提示:
- 安裝zsh-autosuggestions語法歷史記錄插件
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
vim ~/.zshrc
plugins=(zsh-autosuggestions)
最后一行:
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.zshrc
提示:
- 參閱:zsh-autosuggestions
- 軟件安裝位置:
cd ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
- 其他
提示:
- 參閱:
- oh-my-zsh插件
- git插件
- 大多數(shù)插件包括一個(gè)README,它記錄了如何使用它們.
六鸥印、其他
1. 更新
- 設(shè)置更新日期
vi ~/.zshrc
export UPDATE_ZSH_DAYS=13
- 禁用自動(dòng)更新
vi ~/.zshrc
DISABLE_AUTO_UPDATE="true"
- 手動(dòng)更新oh-my-zsh
upgrade_oh_my_zsh
2. 卸載
- 卸載oh-my-zsh
uninstall_oh_my_zsh zsh
3. (.zshrc)源文件內(nèi)容
# 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="/root/.oh-my-zsh"
1.zsh主題
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will 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"
2.是否自動(dòng)更新
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
3.更新周期
# 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.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
4.zsh插件
# Which plugins would you like to load?
# Standard 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.
plugins=(git)
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"
參閱:
更新中......