fish安装与试用

Posted by Max on April 7, 2016
fish安装与试用

1. 前言

fish据说是一个非常友好的跨平台命令行shell。无需配置即可提供语法高亮及智能补全等功能。 在GitHub上有源码

2. 安装

使用yum进行安装。
cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo
yum install fish
其它平台或系统的安装方式请参考官方说明Go fish。 使用如下命令将fish设为默认:
chsh -s /usr/local/bin/fish
同样,将bash设回默认的命令如下:
chsh -s /bin/bash
直接运行命令进入fish环境:
/usr/local/bin/fish

3. 配置

虽然不配置也能用,但是谁会拒绝更易用或更炫酷呢? 与ZSH的oh-my-zsh类似,网上也有一个人搞了个oh-my-fish,可以更快速的上手fish。 直接执行如下命令一步安装
curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish
但是默认的主题并不让我满意。根据说明,切换主题非常简单,命令如下:
omf install lambda   //安装lambda主题
omf theme lambda     //应用lambda主题
omf已经做成了一个微型管理工具。 但是不幸的是,我这样做时出现了如下问题,主题切换不成功
⋊> ~ omf install lambda          //安装lambda主题                                                                                  16:41:26
Theme not installed!
Install it using omf install lambda
⋊> ~ omf install                //显示已安装的主题和扩展                                                                                     16:41:33
basename: invalid option -- 'a'
Try `basename --help' for more information.
Theme not installed!
Install it using omf install default
Theme not installed!
Install it using omf install lambda
issue#179里找到了问题的解决方案,即先卸载omf(命令是omf destory),升级coreutils至最新版本后重新安装omf。 升级之前是8.4
⋊> ~ basename --version                                                                                                                                                                                      23:10:07
basename (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
升级之后是8.25
⋊> ~ basename --version
basename (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
升级过程记录如下:
$ wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.25.tar.xz
$ tar xvf coreutils-8.25.tar.xz
$ cd coreutils-8.25
$ ./configure
$ make
$ sudo make install
PS: 我直接使用新版coreutils覆盖安装是存在风险的,幸好实际操作中没有出现任何问题。保险的做法是./configure --prefix=/your/custom/directory,然后执行echo 'set PATH /your/custom/directory $PATH' >> ~/.config/fish/config.fish,将新版本指给fish/omf来使用。

4. 效果

最后截一张fish效果图吧,直接使用的lambda主题,还未更改配置。 fish-in-lambda