210216

1. 安装zsh(可以直接通过命令行安装)

sudo apt-get install zsh

2.替换默认shell

  • 查看系统自带的shell
cat /etc/shells
  • 将zsh设置为默认shell
chsh -s /bin/zsh

3. 下载安装oh-my-zsh

  • 常规安装(不知道为什么我自己试了没用。。。)
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
  • 通过wget自动安装(不知道为什么我自己试了没用。。。)
wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh
  • 手动安装(自己试了可用)。

第一步:安装git

sudo apt install git

第二步:克隆仓库里面的代码

git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

备份已经有的zsh配置(还是建议备份的,然而我并没有…)

cp ~/.zshrc ~/.zshrc.orig

第三步:创建新的zshrc配置文件
修改zsh配置文件~/.zshrc
代码如下:

# Path to your oh-my-zsh installation.
export 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="xiong-chiamiov-plus"# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="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.
plugins=(git)# User configurationexport PATH=$HOME/bin:/usr/local/bin:$PATH
# export MANPATH="/usr/local/man:$MANPATH"source $ZSH/oh-my-zsh.sh# 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/dsa_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"#color{{{
autoload colors
colorsfor color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval _$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval $color='%{$fg[${(L)color}]%}'
(( count = $count + 1 ))
done
FINISH="%{$terminfo[sgr0]%}"
#}}}#命令提示符
#RPROMPT=$(echo "$RED%D %T$FINISH")
#PROMPT=$(echo "$CYAN%n@$YELLOW%M:$GREEN%/$_YELLOW>$FINISH ")#PROMPT=$(echo "$BLUE%M$GREEN%/
#$CYAN%n@$BLUE%M:$GREEN%/$_YELLOW>>>$FINISH ")
#标题栏、任务栏样式{{{
case $TERM in (*xterm*|*rxvt*|(dt|k|E)term)
precmd () { print -Pn "\e]0;%n@%M//%/\a" }
preexec () { print -Pn "\e]0;%n@%M//%/\ $1\a" }
;;
esac
#}}}#编辑器
export EDITOR=vim
#输入法
export XMODIFIERS="@im=ibus"
export QT_MODULE=ibus
export GTK_MODULE=ibus
#关于历史纪录的配置 {{{
#历史纪录条目数量
export HISTSIZE=10000
#注销后保存的历史纪录条目数量
export SAVEHIST=10000
#历史纪录文件
export HISTFILE=~/.zhistory
#以附加的方式写入历史纪录
setopt INC_APPEND_HISTORY
#如果连续输入的命令相同,历史纪录中只保留一个
setopt HIST_IGNORE_DUPS
#为历史纪录中的命令添加时间戳
setopt EXTENDED_HISTORY      #启用 cd 命令的历史纪录,cd -[TAB]进入历史路径
setopt AUTO_PUSHD
#相同的历史路径只保留一个
setopt PUSHD_IGNORE_DUPS#在命令前添加空格,不将此命令添加到纪录文件中
#setopt HIST_IGNORE_SPACE
#}}}#每个目录使用独立的历史纪录{{{
cd() {
builtin cd "$@"                             # do actual cd
fc -W                                       # write current history  file
local HISTDIR="$HOME/.zsh_history$PWD"      # use nested folders for history
if  [ ! -d "$HISTDIR" ] ; then          # create folder if needed
mkdir -p "$HISTDIR"
fi
export HISTFILE="$HISTDIR/zhistory"     # set new history file
touch $HISTFILE
local ohistsize=$HISTSIZE
HISTSIZE=0                              # Discard previous dir's history
HISTSIZE=$ohistsize                     # Prepare for new dir's history
fc -R                                       #read from current histfile
}
mkdir -p $HOME/.zsh_history$PWD
export HISTFILE="$HOME/.zsh_history$PWD/zhistory"function allhistory { cat $(find $HOME/.zsh_history -name zhistory) }
function convhistory {
sort $1 | uniq |
sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' |
awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }'
}
#使用 histall 命令查看全部历史纪录
function histall { convhistory =(allhistory) |
sed '/^.\{20\} *cd/i\\' }
#使用 hist 查看当前目录历史纪录
function hist { convhistory $HISTFILE }#全部历史纪录 top50
function top50 { allhistory | awk -F':[ 0-9]*:[0-9]*;' '{ $1="" ; print }' | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr | head -n 50 }#}}}#杂项 {{{
#允许在交互模式中使用注释  例如:
#cmd #这是注释
setopt INTERACTIVE_COMMENTS      #启用自动 cd,输入目录名回车进入目录
#稍微有点混乱,不如 cd 补全实用
setopt AUTO_CD#扩展路径
#/v/c/p/p => /var/cache/pacman/pkg
setopt complete_in_word#禁用 core dumps
limit coredumpsize 0#Emacs风格 键绑定
bindkey -e
#bindkey -v
#设置 [DEL]键 为向后删除
#bindkey "\e[3~" delete-char#以下字符视为单词的一部分
WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
#}}}#自动补全功能 {{{
setopt AUTO_LIST
setopt AUTO_MENU
#开启此选项,补全时会直接选中菜单项
#setopt MENU_COMPLETEautoload -U compinit
compinit#自动补全缓存
#zstyle ':completion::complete:*' use-cache on
#zstyle ':completion::complete:*' cache-path .zcache
#zstyle ':completion:*:cd:*' ignore-parents parent pwd#自动补全选项
zstyle ':completion:*' verbose yes
zstyle ':completion:*' menu select
zstyle ':completion:*:*:default' force-list always
zstyle ':completion:*' select-prompt '%SSelect:  lines: %L  matches: %M  [%p]'zstyle ':completion:*:match:*' original only
zstyle ':completion::prefix-1:*' completer _complete
zstyle ':completion:predict:*' completer _complete
zstyle ':completion:incremental:*' completer _complete _correct
zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate#路径补全
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-shlashes 'yes'
zstyle ':completion::complete:*' '\\'#彩色补全菜单
eval $(dircolors -b)
export ZLSCOLORS="${LS_COLORS}"
zmodload zsh/complist
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'#修正大小写
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
#错误校正
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric#kill 命令补全
compdef pkill=kill
compdef pkill=killall
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:*:*:processes' force-list always
zstyle ':completion:*:processes' command 'ps -au$USER'#补全类型提示分组
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'
zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'
zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'
zstyle ':completion:*:corrections' format $'\e[01;32m -- %d (errors: %e) --\e[0m'# cd ~ 补全顺序
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
#}}}##行编辑高亮模式 {{{
# Ctrl+@ 设置标记,标记和光标点之间为 region
zle_highlight=(region:bg=magenta #选中区域
special:bold      #特殊字符
isearch:underline)#搜索时使用的关键字
#}}}##空行(光标在行首)补全 "cd " {{{
user-complete(){
case $BUFFER in
"" )                       # 空行填入 "cd "
BUFFER="cd "
zle end-of-line
zle expand-or-complete
;;
"cd --" )                  # "cd --" 替换为 "cd +"
BUFFER="cd +"
zle end-of-line
zle expand-or-complete
;;
"cd +-" )                  # "cd +-" 替换为 "cd -"
BUFFER="cd -"
zle end-of-line
zle expand-or-complete
;;
* )
zle expand-or-complete
;;
esac
}
zle -N user-complete
bindkey "\t" user-complete
#}}}##在命令前插入 sudo {{{
#定义功能
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
zle end-of-line                 #光标移动到行末
}
zle -N sudo-command-line
#定义快捷键为: [Esc] [Esc]
bindkey "\e\e" sudo-command-line
#}}}#命令别名 {{{
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
alias ls='ls -F --color=auto'
alias ll='ls -al'
alias grep='grep --color=auto'
alias la='ls -a'
alias pacman='sudo pacman-color'
alias p='sudo pacman-color'
alias y='yaourt'
alias h='htop'
alias vim='vim'#[Esc][h] man 当前命令时,显示简短说明
alias run-help >&/dev/null && unalias run-help
autoload run-help#历史命令 top10
alias top10='print -l  ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
#}}}#路径别名 {{{
#进入相应的路径时只要 cd ~xxx
hash -d A="/media/ayu/dearest"
hash -d H="/media/data/backup/ayu"
hash -d E="/etc/"
hash -d D="/home/ayumi/Documents"
#}}}##for Emacs {{{
#在 Emacs终端 中使用 Zsh 的一些设置 不推荐在 Emacs 中使用它
#if [[ "$TERM" == "dumb" ]]; then
#setopt No_zle
#PROMPT='%n@%M %/
#>>'
#alias ls='ls -F'
#fi
#}}}#{{{自定义补全
#补全 ping
zstyle ':completion:*:ping:*' hosts 192.168.1.{1,50,51,100,101} www.google.com#补全 ssh scp sftp 等
#zstyle -e ':completion::*:*:*:hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
#}}}#{{{ F1 计算器
arith-eval-echo() {
LBUFFER="${LBUFFER}echo \$(( "
RBUFFER=" ))$RBUFFER"
}
zle -N arith-eval-echo
bindkey "^[[11~" arith-eval-echo
#}}}####{{{
function timeconv { date -d @$1 +"%Y-%m-%d %T" }# }}}zmodload zsh/mathfunc
autoload -U zsh-mime-setup
zsh-mime-setup
setopt EXTENDED_GLOB
#autoload -U promptinit
#promptinit
#prompt redhatsetopt correctall
autoload compinstall#漂亮又实用的命令高亮界面
setopt extended_globTOKENS_FOLLOWED_BY_COMMANDS=('|' '||' ';' '&' '&&' 'sudo' 'do' 'time' 'strace')recolor-cmd() {region_highlight=()colorize=truestart_pos=0for arg in ${(z)BUFFER}; do((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]## #}}))((end_pos=$start_pos+${#arg}))if $colorize; thencolorize=falseres=$(LC_ALL=C builtin type $arg 2>/dev/null)case $res in*'reserved word'*)   style="fg=magenta,bold";;*'alias for'*)       style="fg=cyan,bold";;*'shell builtin'*)   style="fg=yellow,bold";;*'shell function'*)  style='fg=green,bold';;*"$arg is"*)[[ $arg = 'sudo' ]] && style="fg=red,bold" || style="fg=blue,bold";;*)                   style='none,bold';;esacregion_highlight+=("$start_pos $end_pos $style")fi[[ ${${TOKENS_FOLLOWED_BY_COMMANDS[(r)${arg//|/\|}]}:+yes} = 'yes' ]] && colorize=truestart_pos=$end_posdone}
check-cmd-self-insert() { zle .self-insert && recolor-cmd }check-cmd-backward-delete-char() { zle .backward-delete-char && recolor-cmd }zle -N self-insert check-cmd-self-insertzle -N backward-delete-char check-cmd-backward-delete-char

ps:网上复制的大佬的配置文件

update 210218更新

1. 修改主题

vim ~/.zshrc

主题修改为

ZSH_THEME="agnoster"

2. 安装插件

2.1 命令自动补全
zsh-autosuggestions
下载插件

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
vim ~/.zshrc
plugins=(gitzsh-autosuggestions
)

2.2 高亮命令
zsh-syntax-highlighting
下载插件

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

更新插件

vim ~/.zshrc
plugins=(gitzsh-autosuggestionszsh-syntax-highlighting
)

210220更新

命令行实现搜索

vim ~/.zshrc

更新插件

vim ~/.zshrc
plugins=(gitzsh-autosuggestionszsh-syntax-highlightingweb-search
)

命令行搜索

baidu 天气

210221更新

powerline安装–解决主题的乱码问题

sudo apt-get install powerline

zsh 插件z启用
zsh自带这个插件可以直接调用
用途是可以实现目录跳转

z name //直接跳转到之前cd过得目录

目前使用的zsh插件

vim ~/.zshrc
plugins=(gitzsh-autosuggestionszsh-syntax-highlightingweb-searchz
)

[linux]linux mint zsh安装和配置相关推荐

  1. Linux下Nagios的安装与配置

    Linux下Nagios的安装与配置 2017-03-23 17:40:20     来源:    点击:0 Nagios是企业普遍使用的最具影响力的网络信息监视系统之一,它可以动态监视指定的网络状态 ...

  2. Linux下samba的安装与配置

    physique 博客园 首页 新随笔 联系 管理 订阅 随笔- 203  文章- 0  评论- 33 Linux下samba的安装与配置 转载来源:http://blog.chinaunix.net ...

  3. linux下jdk的安装与配置jdk-6u45-linux-i586.bin

    linux下jdk的安装与配置 一.安装JDK从sun网站上直接下载JDK:http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45- ...

  4. linux 安装cvs,linux下cvs详细安装和配置.docx

    Linux 下cvs详细安装和配置 2009-03-18 14:37:12 标签:[推送到技术圈] 版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始岀处 作者信息和本声明.否则将追究 ...

  5. 在Linux系统下XAMPP安装与配置(可离线安装)

    在Linux系统下XAMPP安装与配置(可离线安装) XAMPP网址:https://www.apachefriends.org/zh_cn/index.html 首先找到自己需要安装的版本下载地址( ...

  6. LAMP-架构环境网站搭建;在Apache Web服务器上部署PHPBB3网站详细步骤;Linux+Apache2+PHP+MySQL 安装和配置

    在Apache Web服务器上部署PHPBB3网站 LAMP-架构环境网站搭建;在Apache Web服务器上部署PHPBB3网站详细步骤:Linux+Apache2+PHP+MySQL 安装和配置 ...

  7. linux系统配置Vim命令,vim配置 LINUX操作系统VIM的安装和配置

    vim和emacs是linux环境下的文本编辑利器,关于vim和emacs谁更优秀的话题从来没有断过,我在这里就不再评判了,vim是linux下的默认编辑器,学好了vim将会一生受用,使用vim编辑代 ...

  8. linux mrtg 安装,17.1.2 Linux下MRTG的安装与配置

    17.1.2  Linux下MRTG的安装与配置 MRTG通过SNMP从设备中得到使用设备(如交换机)的网络流量信息,并把PNG格式图形以HTML方式显示出来,便于网络管理员对所监控设备(交换机)进行 ...

  9. linux下Mysql 的安装、配置、数据导入导出

    为什么80%的码农都做不了架构师?>>>    <p><span>MySQL</span><span>是一种</span> ...

  10. linux下postgresql服务,Linux下PostgreSQL数据库安装、配置与日常服务管理

    1. 数据库安装与配置步骤 安装环境准备 操作系统: Oracle Linux Server 6.5 IP 地址: 192.168.6.177 版本信息: MySQL Community Server ...

最新文章

  1. Authentication method 'caching_sha2_password' not supported by any of the available plugins.
  2. Unbuntu18.04通过apt源方式安装mysql5.7.22
  3. 用Fiddler抓取手机APP数据包
  4. Tensorflow图像通道合并,IndexError: too many indices for array
  5. 虹康三期倒垃圾时间和理发地点
  6. .net 解析Transfer-Encoding:chunked 秒掉网上无用方案
  7. 有些窗口底部被任务栏挡住了_开始使用 Tint2 吧,一款 Linux 中的开源任务栏
  8. Oracle11g数据库监听配置
  9. 爬虫学习之-Python list 和 str 互转
  10. 比较好的论坛(个人认为)
  11. 超级符号就是超级创意_超级食物
  12. stm32f103 ds18B20 驱动及芯片资料
  13. cannot access memory
  14. Scrapy图片分类异步下载
  15. 找出程序耗费 CPU 的函数
  16. 2020 年 7 月编程语言排行榜
  17. 【大数据开发】SparkCore——利用广播变量优化ip地址统计、Spark2.x自定义累加器
  18. python 抓取淘宝价格信息
  19. sklearn笔记26 pandas批量处理成绩表
  20. lua string 库

热门文章

  1. 会议平板一体机常见触摸屏幕故障分析与解决
  2. 【张朝阳的物理课笔记】 5. 波动方程,声音在空气中的传播速度
  3. 《学会提问》-批判性思维
  4. html怎么用2个caption不换行,caption怎么用
  5. 获取两个指定数之间的随机数(万能公式)
  6. LFS-初入门第一篇(准备环境)
  7. 做到这几点在家也能拍出好看的证件照
  8. 常规WebRoot项目在Idea中通过tomcat运行
  9. 服务器系统事件6013,系统-事件ID:6013
  10. 雅虎邮箱pop服务器,使用Yahoo.com.cn的POP和SMTP