Z Shell - 用强大的ZSH把Bash换掉
来源:互联网 发布:淘宝买机油 编辑:程序博客网 时间:2024/05/17 04:51
Z Shell - 用强大的ZSH把Bash换掉
大多数的Linux用户偏爱Bash,因为发行版通常默认的就是它。
Bash确实是不错的Shell,但仍有用很多不尽人意的地方,如自动补全的功能不够强大,定位较长路径不够方便,命令历史管理不够完善等。
我是经一个法国朋友(超级大Geek..)介绍使用zsh,功能十分强大..推荐给大家!
1.安装zsh
对于一般的Ubuntu系统,配置好正确的源之后,就能直接键入以下命令安装:
sudo apt-get install zsh
2.配置zsh
zsh的配置是一门大学问,这里不赘述,直接给出一个配置文件,大家可以下载后放入zsh配置文档直接使用。(我的一个法国朋友手配的,相当顺手)
把.zshrc拷贝到相应用户的home目录即可
(也可以把你的bash的配置文件(~/.bash_prorile或者~/.profile等)给拷贝到zsh的配置文件~/.zshrc里,因为zsh兼容bash)
3.取代bash,设为默认shell
sudo usermod -s /bin/zsh username
或者
chsh -s /bin/zsh
ZSH神器技巧介绍
(后续补足哈)
在Ubuntu上安装zsh
本文以Ubuntu 12.04 LTS为例,安装目前比较流行的zsh的配置oh-my-zsh。 oh-my-zsh最初是在OS X上供人使用,使用方法见此处。在Ubuntu上安装oh-my-zsh稍有不同。
安装
先安装zsh和git,同时移除之前可能的oh-my-zsh的安装。
sudo
apt-get
install
zsh git
if
[ -d ~/.oh-my-zsh ];
then
rm
-r ~/.oh-my-zsh
fi
手动安装zsh是用于Ubuntu的 sh
比较诡异,不识别 source
这个指令。装好zsh后仿OS X
wget https:
//github
.com
/robbyrussell/oh-my-zsh/raw/master/tools/install
.sh -O - | zsh
然后把shell切换成zsh,并重启计算机。
chsh -s `
which
zsh`
sudo
shutdown
-r 0
关于这个诡异问题的详细讨论见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。1
cd
~/.fonts/ && git clone https:
//github
.com
/scotu/ubuntu-mono-powerline
.git &&
cd
~
- 在
~/.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
的配置文件里面了。
# 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
- Z Shell - 用强大的ZSH把Bash换掉
- Linux终极shell-Z Shell--用强大的zsh & oh-my-zsh把Bash换掉
- Linux终极shell-Z Shell--用强大的zsh & oh-my-zsh把Bash换掉
- 把 Mac 上的 bash 换成 zsh
- 把 Mac 上的 bash 换成 zsh
- linux下强大的shell前端--zsh
- bash、dash与zsh shell
- oh-my-zsh 强大漂亮的shell命令
- 强大的Oh my Zsh
- .bash和.zsh的切换
- zsh和bash的区别
- 好用的shell——zsh
- zsh与bash设置环境变量的不同点
- 爽爆天的shell - zsh - 基于“Oh-My-Zsh”
- Shell Zsh
- zsh切换bash bash切换zsh
- zsh切换bash bash切换zsh
- Bash 强大的History 命令
- asp .NET弹出窗口 汇总
- ListView 多选后,获取所有选中项
- Rotate List
- 工厂模式 (C#)
- 赴一场远行,抵一度荒年
- Z Shell - 用强大的ZSH把Bash换掉
- 数据结构 串
- 研大考研:2015考研英语阅读策略
- 【LeetCode】Multiply Strings
- smtp匿名邮件发送小记
- cocos2dx-3.0(13)------SpriteBatchNode与SpriteFrameCache加快渲染
- 图形加速卡技术
- Mac ssh 远程登录 无需密码验证 设置
- Android自定义对话框(Dialog)位置,大小