linux shell zsh,Linux终极shell Z Shell 用强大的zsh & oh-my-zsh把Bash换掉

Bash确实是不错的Shell,但仍有用不少不尽人意的地方,如自动补全的功能不够强大,定位较长路径不够方便,命令历史管理不够完善等。javascript

介绍使用zsh,功能十分强大…推荐给你们!java

1 介绍zsh

1.1 Linux shell

经常使用的Shell有这么几种,sh、bash、csh等,想知道你的系统有几种shell,能够经过如下命令查看:linux

cat /etc/shells

未安装zsh,显示结果以下:

/bin/sh

/bin/bash

/sbin/nologin

/bin/dash

/bin/tcsh

/bin/cshgit

1.2 zsh简介

Zsh是一个Linux下强大的shell, 因为大多数Linux产品安装,以及默认使用bash shell, 可是丝绝不影响极客们对zsh的热衷, 几乎每一款Linux产品都包含有zsh,一般能够用apt-get、urpmi或yum等包管理器进行安装github

Zsh具备如下主要功能

开箱即用、可编程的命令行补全功能能够帮助用户输入各类参数以及选项

在用户启动的全部shell中共享命令历史

经过扩展的文件通配符,能够不利用外部命令达到find命令通常展开文件名

改进的变量与数组处理

在缓冲区中编辑多行命令

多种兼容模式,例如使用/bin/sh运行时能够假装成Bourne shell

能够定制呈现形式的提示符;包括在屏幕右端显示信息,并在键入长命令时自动隐藏

可加载的模块,提供其余各类支持:完整的TCP与Unix域套接字控制,FTP客户端与扩充过的数学函数

彻底可定制化web

1.3 zsh与oh-my-zsh终极配置

以前是由于看到这篇文章:终极Shell——Zsh 才选择使用zsh,被它的自动完成、补全功能吸引了。shell

这也是“工欲善其事,必先利其器”系列文章。vim

选择oh-my-zsh, oh-my-zsh是基于zsh的功能作了一个扩展,方便的插件管理、主题自定义,以及漂亮的自动完成效果。数组

在Github上找关于zsh的项目时发现的,试用了一下以为很方便,不用像上面文章里面提到的那么复杂,配置一些插件的名称便可使用相应的功能。

2 安装zsh

2.1 安装zsh

对于通常的Ubuntu系统,配置好正确的源以后,就能直接键入如下命令安装:

sudo apt-get install zsh

对于linux系统,直接使用如下命令安装:

yum -y install zsh

2.2 配置zsh

把.zshrc拷贝到相应用户的home目录便可

(也能够把你的bash的配置文件(/.bash_prorile或者/.profile等)给拷贝到zsh的配置文件~/.zshrc里,由于zsh兼容bash)

使用 Zsh 扩展集合:oh-my-zsh

oh-my-zsh 帮咱们整理了一些经常使用的 Zsh 扩展功能和主题:https://github.com/robbyrussell/oh-my-zsh

咱们无需本身去捣搞 Zsh,直接用 oh-my-zsh 就足够了,若是你想继续深造的话那再去弄。

先安装 git:sudo yum install -y git

安装 oh-my-zsh(这个过程可能会有点慢,或者须要重试几回):wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh

安装效果图以下:

c65701b25921770a0c5411b11a295ba0.png

在以 root 用户为前提下,oh-my-zsh 的安装目录:/root/.oh-my-zsh

在以 root 用户为前提下,Zsh 的配置文件位置:/root/.zshrc

为 root 用户设置 zsh 为系统默认 shell:chsh -s /bin/zsh root

若是你要从新恢复到 bash:chsh -s /bin/bash root

如今你关掉终端或是从新连上 shell,如今开头是一个箭头了,以下图:

f39fd6aa53fd798b7ebbd8e27e889ee8.png

如今zsh和oh-my-zsh都安装好了,如今重点讲下zsh的配置!

建立~/.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=/home/amoscykl/.oh-my-zsh

# Set name of the theme to load. Optionally, if you set this to "random"

# it'll load a random theme each time that oh-my-zsh is loaded.

# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

# zhs的主题

ZSH_THEME="ys"

# Set list of themes to load

# Setting this variable when ZSH_THEME=random

# cause zsh load theme from this variable instead of

# looking in ~/.oh-my-zsh/themes/

# An empty array 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"

# Uncomment the following line to disable bi-weekly auto-update checks.

# DISABLE_AUTO_UPDATE="true"

# 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.

# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"

# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?

# ZSH_CUSTOM=/path/to/new-custom-folder

# 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)

# Add wisely, as too many plugins slow down shell startup.

# z命令快速跳转目录 x命令解压一切文件 命令行能够直接google

plugins=(

git z zsh-autosuggestions extract web-search zsh-syntax-highlighting

)

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"

#

保存并执行命令,使配置生效:

cd ~ && source .zshrc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值