刚安装好deepin,使用了一段时间发现一个很大的不足:自带的终端不能使用tab键,于是上网一阵捣鼓,发现了一个神器可以用来替换自带的终端,那就是本文要安装的zsh。

第一步:安装zsh

$ sudo apt-get install -y zsh

这只是一个普普通通的bash,它的强大之处在于配置以及对插件的支持,接下来配置zsh。

第二步:安装oh-my-zsh

此步骤之前需要安装gi:$ sudo apt install git(一个命令的事~^_^)

安装on-my-zsh,三种方式,任选其一

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh

安装成功后的样子是这样的:

这里有个坑,本人安装后并没有是这样的,而是提示:

This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

(2)  Populate your ~/.zshrc with the configuration recommended
     by the system administrator and exit (you will need to edit
     the file by hand, if so desired).

谷歌翻译一波,大致应该是配置文件没起到作用,于是网上下载了一个配置文件,一试还真可以。下面贴出配置文件源码:

#color{{{
autoload colors
colors
 
for 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")

#命令提示符 {{{
RPROMPT=$(echo '%{\033[31m%}%D %T%{\033[m%}')
PROMPT=$(echo '%{\033[34m%}%M%{\033[32m%}%/
%{\033[36m%}%n %{\033[01;31m%}>%{\033[33m%}>%{\033[34m%}>%{\033[m%} ')

#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_COMPLETE
 
autoload -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 l='ls'
alias grep='grep --color=auto'
alias la='ls -a'
alias vim='sudo vim'
alias server='telnet 172.16.99.31 -l fengchunwang -E'
 
#[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 redhat
 
setopt correctall
autoload compinstall
 
#漂亮又实用的命令高亮界面
setopt extended_glob
 TOKENS_FOLLOWED_BY_COMMANDS=('|' '||' ';' '&' '&&' 'sudo' 'do' 'time' 'strace')
 
 recolor-cmd() {
     region_highlight=()
     colorize=true
     start_pos=0
     for arg in ${(z)BUFFER}; do
         ((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]## #}}))
         ((end_pos=$start_pos+${#arg}))
         if $colorize; then
             colorize=false
             res=$(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';;
             esac
             region_highlight+=("$start_pos $end_pos $style")
         fi
         [[ ${${TOKENS_FOLLOWED_BY_COMMANDS[(r)${arg//|/\|}]}:+yes} = 'yes' ]] && colorize=true
         start_pos=$end_pos
     done
 }
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-insert
 zle -N backward-delete-char check-cmd-backward-delete-char

PATH=${PATH}:/opt/toolchains/uclibc-crosstools-gcc-4.2.3-3/usr/bin/
PATH=${PATH}:~/bin/
# PATH=${PATH}:/home/arthur/work/WRT54GL-US_v4.30.13/tools/brcm/hndtools-mipsel-linux-3.2.3/bin
export PATH
export GIT_PROXY_COMMAND=~/bin/proxy-wrapper

大家在下面新建一个文件名为.zshrc,然后把源码放进去即可。

如果是第一种方式安装的则默认bash就是zsh,其他方式需要替换:chsh -s /bin/zsh

第三步:安装主题

https://github.com/robbyrussell/oh-my-zsh/wiki/Themes这个网站里面有各种主题,大家按需下载即可。访问可能有点慢~~

  • 在安装之前先保证自己电脑上有powerline font,因为该主题会使用到这些特殊的字符,使用下面语句检测是否存在该主题需要的特殊字符
    $ echo "\ue0b0 \u00b1 \ue0a0 \u27a6 \u2718 \u26a1 \u2699"
    正确的输出应该是这样:

  • 如果没有,就安装该字体库:
    $ sudo apt-get install fonts-powerline

sudo ls ~/.oh-my-zsh/themes   查看有哪些主题

vim ~/.zshrc  打开配置文件

修改zsh_theme后面的字符串为自己想要的主题名即可。

修改后$ source ~/.zshrc   刷新下即可。

参考:https://www.jianshu.com/p/27c8088dc8f7

deepin安装zsh以及简单配置相关推荐

  1. Kali Linux虚拟机安装完整安装过程及简单配置(视频)

    Kali Linux虚拟机安装完整安装过程及简单配置 点击上述视频播放 转载于:https://www.cnblogs.com/wildernessdreams/p/8408804.html

  2. rhel mysql安装_RHEL6.4下MySQL安装方法及简单配置

    1.MySQL安装方法简介 1.rpm包yum安装 2.通用二进制包安装 3.源码编译安装 注意:实验所采用的系统平台为:RHEL6.4 2.rpm ins 首页 → 数据库技术 背景: 阅读新闻 R ...

  3. 快捷配置mysql_windows下的mysql的快捷安装方法和简单配置

    windows下的mysql的快捷安装方法和简单配置 作者:兴邦开发部 人气: 发表时间:2015年12月14日 [文章内容简介]:关于windows下的mysql的安装有很多种形式,下面来介绍一种简 ...

  4. ubuntu安装zsh及环境配置

    ubuntu安装zsh及环境配置 MacBook 安装 zsh 个人很喜欢使用zsh,它的终端显示很清晰,命令都很友好,使用git时,直接可以看到当前分支和修改状态 zsh安装 1.查看当前系统装了哪 ...

  5. oracle xe 安装配置,(转)oracle 10g xe 我的安装实践及简单配置过程

    (转)oracle 10g xe 我的安装实践及简单配置过程 我的安装过程 1.编辑 /etc/apt/sources.list : sudo cp /etc/apt/sources.list /et ...

  6. 在Ubuntu-server下安装i3wm并简单配置

    arch只提供了tty,我们需要自己配置一个漂亮的桌面.你可以选择继承好的GNOME.Deepin等桌面.但是他们都包含了许多你可能并不能用到的工具和插件.i3wm是一个窗口管理器,它提供了最基础的窗 ...

  7. Deepin - 安装zsh及oh-my-zsh的踩坑记录

    第一次写,没啥规划,随便记录的 1. 安装zsh[重要] 2. 安装oh-my-zsh[重要] 2.1 查看shell 2.2 切换默认shell[重要] ~~2.3 .oh-my-zsh目录完全授权 ...

  8. Manjaro 安装后的简单配置与美化以及小技巧 (2019.12.15 更新)

    一.双显卡驱动 说明 Intel+Nvidia在Linux下的支持并不是很好,如果配置不当会出现耗电增加或是屏幕glich等问题,有几种方案可以实现双显卡的和谐共存,Manjaro自带bumblebe ...

  9. Mac 安装zsh 以及powerlevel10k配置

    安装z s h 教程 1.使用git地址在线安装,这个地址在国内比较快 git clone https://gitee.com/mirrors/oh-my-zsh.git && cd ...

最新文章

  1. redis的通用命令 || redis持久化机制:(RDB  ||  AOF)
  2. Ubuntu配置交叉编译环境
  3. 白话Elasticsearch67-不随意调节jvm和thread pool的原因jvm和服务器内存分配的最佳实践
  4. iOS开发之邮件发送代码
  5. C#中使用JavaScriptSerializer类实现序列化与反序列化
  6. HTML DOM教程 22-HTML DOM Form 对象
  7. asp.net中生命周期的浅析
  8. Dojo学习笔记(7. dojo.dom)
  9. java 图片拼接_Java拼接多张图片,可以连接在一起 | 学步园
  10. JN_0005:PS改变图片指定内容颜色
  11. gradle java ide_用最简单的gradle代码,解决你java项目中的jar依赖之苦
  12. Unity3D加载资源的四种方式
  13. (可远程)开源手机app控制c51单片机,附微信小程序控制
  14. ADNI数据库数据集下载权限申请
  15. word文字上下间距怎么调_word上下文字间距 word字体上下间距怎么调整
  16. handsontable使用及遇到的坑--mergeCell、合并单元格
  17. 谷歌三大核心技术:from--http://blog.csdn.net/together_cz/article/details/66969003
  18. Excel在统计分析中的应用—第五章—统计指数-Part5- 综合指数(费雪指数)
  19. HG30-3a型数字式多功能校准仪
  20. IDM下载器免费高质量的Win下载工具无使用限制

热门文章

  1. 滴滴司机被醉酒乘客殴打 官方回应来了...
  2. 你们期待的小屏旗舰来了: 骁龙855 没有刘海!
  3. 「十年老测试」测试员的职场之路
  4. 2021年吉林高考成绩怎么查询,2021年吉林高考成绩查询登录网址入口怎么查 附查询方法...
  5. 用python效率办公_如何用Python提高办公(Excel)效率?
  6. 寻找素数分配线程算法
  7. c++ 使用正则匹配url
  8. mysql设置空值显示null_mysql的空值与NULL的区别
  9. python实现解析oui.txt并抽取MAC前缀及组织名称
  10. 解决linux系统WIFI无法使用5GHz频率的问题