zsh 和 fish 安装与使用

来源:互联网 发布:手机淘宝怎么进咸鱼 编辑:程序博客网 时间:2024/06/06 23:03

Ubuntu Oh My Zsh and fish

俗话说 工欲善其事,必先利其器。
在Ubuntu下面用的最多的就是Terminal 和 Vim了。
Ubuntu 默认的Shell 为bash,效率几乎为0, 市面上有很多Shell ,笔者用的时间长的也就数,fish和 zsh 了。

fish 优点: 开箱即用, 安装好就可以使用,省去麻烦的配置,好像也有 oh my fish 这个项目,有兴趣的可以去了解下。
zsh 优点 : 有oh my zsh 提供强大的插件,还有主题配置。

Ubuntu 安装fish 并且设为默认shell

sudo apt install fishchsh -s $(which fish)
chsh -s 后面加路径 : 设置当前用户默认shellwhich fish :查看fish程序的路径chsh -s $(which fish) : 设置fish为当前用户默认shell

fish shell 实例


fish

笔者还是推荐 zsh,接下来讲描述安装 zsh , 还有配置 oh my zsh 。

安装zsh 和定制zsh

  1. 安装 zsh , git 和 wget
    sudo apt install zsh git wget
  2. 确认安装zsh
    zsh --versionzsh 5.1.1 (x86_64-ubuntu-linux-gnu)
  3. 获取并自动安装 oh my zsh
    wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
  4. 设置默认shell为zsh
    chsh -s $(which zsh)
  5. 设置zsh的参数
    执行  ls ~/.oh-my-zsh/将会显示 oh-my-zsh 的程序目录

oh my zsh 文件夹


oh my zsh 文件夹
plugins 文件夹 为 zsh 的插件, oh my zsh 为用户提供了很多的插件, 自己也可以下载插件,插件的用法下面会提到themes  文件夹为zsh 的主题,笔者自用为 "ys"
编辑 ~/.zshrcvim ~/.zshrcZSH_THEME="robbyrussell" : 主题配置比如笔者修改主题为 "ys"  : ZSH_THEME="ys"plugins=(git) : 插件配置,oh my zsh 默认启用gitoh my zsh 为大家提供了很多插件,也可以自己安装,安装插件下面会提到。

高亮你的可用命令

安装 zsh-syntax-highlighting
git clone git://github.com/jimmijj/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting然后编辑 ~/.zshrcplugins=(zsh-syntax-highlighting)

zsh 定义快捷键

zsh 很方便的定义快捷键,比如 把 ls -a 定义为 la,编辑 ~/.zshrc,最尾部加入:
alias la='la -a'

ys主题效果


ys主题

卸载 oh my zsh
当然有安装肯定有办法卸载了,但是oh my zsh 那么好用,你一定会爱不释手的

uninstall_oh_my_zsh

注:Ubuntu 版本为16.04