美文网首页LinuxUbuntu学步者我用 Linux
我的Ubuntu16.0.4必须安装zsh &&

我的Ubuntu16.0.4必须安装zsh &&

作者: Ricsy | 来源:发表于2019-03-19 12:01 被阅读4次


    目录


    一、zsh说明

    • zsh是一个Linux下强大的shell, 由于大多数Linux产品安装以及默认使用bash shell, 但是丝毫不影响极客们对zsh的热衷, 几乎每一款Linux产品都包含有zsh,通常可以用apt-get、urpmi或yum等包管理器进行安装.

    • zsh是bash的增强版,其实zsh和bash是两个不同的概念,zsh更加强大。

    • 通常zsh配置起来非常麻烦,且相当的复杂,所以oh-my-zsh是为了简化zsh的配置而开发的,因此oh-my-zsh算是zsh的配置.

    • Ubuntu16.0.4_Server_64_no_au_zsh

    说明:

    参阅:oh-my-zsh


    二、准备

    • 查看系统当前使用的shell
      echo $SHELL
    • 查看系统自带哪些shell
      cat /etc/shells
    • oh-my-sh相关文件位置
    • vim ~/.zshrc

    说明:

    • ~表示用户名目录,<.FileName>表示隐藏文件.

    三、安装zsh

    1. 开始安装

    apt install zsh -y

    提示:

    • 查看系统自带哪些shell
      cat /etc/shells

    表明已经安装好zsh.

    2. 配置

    • zsh设为默认shell
      chsh -s /bin/zsh
      reboot

    提示:

    • 若总是报错chsh: PAM: Authentication failure
      直接修改用户的配置
      vim /etc/passwd/
    • 查看系统当前使用的shell
      echo $SHELL

    表明已经将zsh设置为默认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 -)"


    五、个性化


    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",那么每次打开一个新的终端窗口时,电脑会随机选择一个主题使用,
      echo $RANDOM_THEME可输出当前主题名称.

    • 如果你想从你最喜欢的主题列表中选择随机主题,那么ZSH_THEME="random"
      ZSH_THEME_RANDOM_CANDIDATES的值设置为你喜欢的主题名称
      例如:
      ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )


    2. 插件


    • 安装incr自动补全插件推荐

    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

    默认开启的插件,提供了大量 git 的alias.

    1. extract

    功能强大的解压插件,所有类型的文件解压一个命令x全搞定,再也不需要去记tar后面到底是哪几个参数了.

    1. z

    强大的目录自动跳转命令,会记忆你曾经进入过的目录,用模糊匹配快速进入你想要的目录.


    • 安装autojump自动跳转插件

    apt install autojump
    vi ~/.zshrc

    . /usr/share/autojump/autojump.sh
    

    source ~/.zshrc

    提示:

    • 参阅:autojump1autojump2
    • 说明文档: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. 更新

    • 设置更新日期
      vi ~/.zshrc
    export UPDATE_ZSH_DAYS=13
    
    • 禁用自动更新
      vi ~/.zshrc
    DISABLE_AUTO_UPDATE="true"
    
    • 手动更新oh-my-zsh
      upgrade_oh_my_zsh

    2. 卸载

    • 卸载oh-my-zsh
      uninstall_oh_my_zsh zsh

    3. (.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="/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.是否自动更新
    # 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"
    

    参阅:


    相关文章

      网友评论

        本文标题:我的Ubuntu16.0.4必须安装zsh &&

        本文链接:https://www.haomeiwen.com/subject/pqvwmqtx.html