您的位置:首页 > 其它

在Ubuntu上安装zsh

2016-07-23 13:14 267 查看
本文以Ubuntu 12.04 LTS为例,安装目前比较流行的zsh的配置oh-my-zsh。 oh-my-zsh最初是在OS X上供人使用,使用方法见此处。在Ubuntu上安装oh-my-zsh稍有不同。


安装

先安装zsh和git,同时移除之前可能的oh-my-zsh的安装。

?
手动安装zsh是用于Ubuntu的 
sh
 比较诡异,不识别 
source
 这个指令。装好zsh后仿OS
X

?
然后把shell切换成zsh,并重启计算机。

?
关于这个诡异问题的详细讨论见github上此issue


配置





oh-my-zsh有大量精美主题托管在项目中,可以在此预览 https://github.com/robbyrussell/oh-my-zsh/wiki/themes,我看中了其中最拉风的一款agnoster。把配置过程记录如下。 为了能够显示诸如分支(branch)、闪电(这个符号应该指拿到root权限)、错误(红色叉叉)、后台(一个齿轮)的各种符号,必须使用一个patch过的字体,在ubuntu下默认是Ubuntu Mono,OS X下坐着配的是Menlo,很多常见的等宽字体都打好了patch,当然也可以自己手动打patch。

?
在 
~/.zshrc
 把主题设置为 
agnoster

在 
~/.zshrc
 设定 
DEFAULT_USER
 变量可以使得即使登陆在本机(即非SSH到远程)时也能显示“user@hostname”

这是我做的效果,Solarized Dark colorscheme这个配色没有适用于Ubuntu Terminal的。





以下是我的 
.zshrc
 ,只开了git一个plugin,还有很多plugin在 
~/.oh-my-zsh/plugin/
 目录下,原来的sublime的plugin有点bug,我就放在我的
.zshrc
的配置文件里面了。
https://gist.github.com/4015090.js?file=.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"

# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"

# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"

# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"

# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"

# Which plugins would you like to load? (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)
plugins=(git)

alias st='/usr/bin/sublime-text'

source $ZSH/oh-my-zsh.sh

# Customize to your needs...
export PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

# optionally set DEFAULT_USER in ~/.zshrc to your regular username to hide the “user@hostname” info when you’re logged in as yourself on your local machine.
DEFAULT_USER=tangkai@virtual-machine

转自:http://logicmd.net/2012/11/installing-zsh-on-ubuntu/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: