分享一个zsh配置文件
Tofloor
poster avatar
Bluek404
deepin
2015-01-02 11:20
Author
DeepinScreenshot20150102030831.png
修改自: http://blog.chinaunix.net/uid-26495963-id-3193686.html

去掉了一般用户用不到的功能(比如把里面的命令别名都删了,刚开始还是打全命令学的快一点),以及修改了一下命令提示符样式和加入历史记录补全
Shift+↑或↓可以自动补全历史记录
比如你上次输入了print 123
然后想再使用一遍
但是又输入了很多别的命令
一条一条翻历史记录太慢
就可以先输入前几个字符,比如prin
然后按Shift+↑就可以快速补全成print 123了

把下面的文本保存到用户目录的 .zshrc 文件中就行
  1. # 历史纪录条目数量
  2. export HISTSIZE=10000
  3. # 注销后保存的历史纪录条目数量
  4. export SAVEHIST=10000
  5. # 历史纪录文件
  6. export HISTFILE=~/.zsh_history
  7. # 以附加的方式写入历史纪录
  8. setopt INC_APPEND_HISTORY
  9. # 如果连续输入的命令相同,历史纪录中只保留一个
  10. setopt HIST_IGNORE_DUPS
  11. # 为历史纪录中的命令添加时间戳
  12. setopt EXTENDED_HISTORY
  13. # 在命令前添加空格,不将此命令添加到纪录文件中
  14. setopt HIST_IGNORE_SPACE
  15. # 输入前半部分然后 Shift + ↑/↓ 自动补全命令历史
  16. bindkey "^[[1;2A" history-search-backward
  17. bindkey "^[[1;2B" history-search-forward
  18. # 启用颜色显示
  19. autoload colors
  20. colors
  21. # 启用ls颜色分类
  22. ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
  23. # 自定义命令提示符
  24. PROMPT=$(echo -e "\033[36m%M \033[32m> \033[36m%n \033[32m> \033[0m%~\n%{$fg[green]%}>> %{$reset_color%}")
  25. # 自动补全功能
  26. setopt AUTO_LIST
  27. setopt AUTO_MENU
  28. # 启用自动补全TAB选单
  29. zstyle ':completion:*' menu select
  30. # 路径补全
  31. zstyle ':completion:*' expand 'yes'
  32. zstyle ':completion:*' squeeze-slashes 'yes'
  33. zstyle ':completion::complete:*' '\\'
  34. # 修正大小写
  35. zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
  36. # 错误校正
  37. zstyle ':completion:*' completer _complete _match _approximate
  38. zstyle ':completion:*:match:*' original only
  39. zstyle ':completion:*:approximate:*' max-errors 1 numeric
  40. # kill 命令补全
  41. compdef pkill=killall
  42. zstyle ':completion:*:*:kill:*' menu yes select
  43. zstyle ':completion:*:*:*:*:processes' force-list always
  44. zstyle ':completion:*:processes' command 'ps -au$USER'
  45. # 补全类型提示分组
  46. zstyle ':completion:*:matches' group 'yes'
  47. zstyle ':completion:*' group-name ''
  48. zstyle ':completion:*:options' description 'yes'
  49. zstyle ':completion:*:options' auto-description '%d'
  50. zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'
  51. zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'
  52. zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'
  53. zstyle ':completion:*:corrections' format $'\e[01;32m -- %d (errors: %e) --\e[0m'
Copy the Code

2015/1/2更新:
删除oh-my-zsh依赖
Reply Favorite View the author
All Replies
MattD
deepin
2015-01-02 18:35
#1
前提:本机需要安装有oh-my-zsh
Reply View the author
Bluek404
deepin
2015-01-03 00:27
#2
前提:本机需要安装有oh-my-zsh
Deepin默认有的
Reply View the author