Ubuntu | 安裝oh-my-zsh



目錄


一搬卒、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

說明:

參閱: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主題只泼、更多主題

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

  1. git

默認(rèn)開啟的插件枯途,提供了大量 git 的alias.

  1. extract

功能強(qiáng)大的解壓插件忌怎,所有類型的文件解壓一個(gè)命令x全搞定籍滴,再也不需要去記tar后面到底是哪幾個(gè)參數(shù)了.

  1. 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

提示:

  • 參閱:autojump1孽惰,autojump2
  • 說明文檔:cd /usr/share/doc/autojump/README.Debian
  • 軟件安裝位置:cd /usr/share/autojump

  • 安裝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

  • 其他

提示:


六鸥印、其他

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"

參閱:


更新中......


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末勋功,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子库说,更是在濱河造成了極大的恐慌狂鞋,老刑警劉巖,帶你破解...
    沈念sama閱讀 207,113評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件潜的,死亡現(xiàn)場離奇詭異骚揍,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)啰挪,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,644評論 2 381
  • 文/潘曉璐 我一進(jìn)店門信不,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人亡呵,你說我怎么就攤上這事抽活。” “怎么了锰什?”我有些...
    開封第一講書人閱讀 153,340評論 0 344
  • 文/不壞的土叔 我叫張陵下硕,是天一觀的道長丁逝。 經(jīng)常有香客問我,道長梭姓,這世上最難降的妖魔是什么果港? 我笑而不...
    開封第一講書人閱讀 55,449評論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮糊昙,結(jié)果婚禮上辛掠,老公的妹妹穿的比我還像新娘。我一直安慰自己释牺,他們只是感情好萝衩,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,445評論 5 374
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著没咙,像睡著了一般猩谊。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上祭刚,一...
    開封第一講書人閱讀 49,166評論 1 284
  • 那天牌捷,我揣著相機(jī)與錄音,去河邊找鬼涡驮。 笑死暗甥,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的捉捅。 我是一名探鬼主播撤防,決...
    沈念sama閱讀 38,442評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼棒口!你這毒婦竟也來了寄月?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,105評論 0 261
  • 序言:老撾萬榮一對情侶失蹤无牵,失蹤者是張志新(化名)和其女友劉穎漾肮,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體茎毁,經(jīng)...
    沈念sama閱讀 43,601評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡克懊,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,066評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了充岛。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片保檐。...
    茶點(diǎn)故事閱讀 38,161評論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖崔梗,靈堂內(nèi)的尸體忽然破棺而出夜只,到底是詐尸還是另有隱情,我是刑警寧澤蒜魄,帶...
    沈念sama閱讀 33,792評論 4 323
  • 正文 年R本政府宣布扔亥,位于F島的核電站场躯,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏旅挤。R本人自食惡果不足惜踢关,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,351評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望粘茄。 院中可真熱鬧签舞,春花似錦、人聲如沸柒瓣。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,352評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽芙贫。三九已至搂鲫,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間磺平,已是汗流浹背魂仍。 一陣腳步聲響...
    開封第一講書人閱讀 31,584評論 1 261
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留拣挪,地道東北人擦酌。 一個(gè)月前我還...
    沈念sama閱讀 45,618評論 2 355
  • 正文 我出身青樓,卻偏偏與公主長得像媒吗,于是被迫代替她去往敵國和親仑氛。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,916評論 2 344