Advertisement
Guest User

Untitled

a guest
Jul 30th, 2022
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.93 KB | None | 0 0
  1. # Zsh config, managed by ZI
  2. # Author: JC Zhang <[email protected]>
  3.  
  4. if [[ -r "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  5.     source "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh"
  6. fi
  7.  
  8. # --- Auto start Tmux else in embedded mode
  9. if [[ -z $TMUX && $- == *i* ]]; then
  10.     if [[ ! "$(</proc/$PPID/cmdline)" =~ "/usr/bin/(dolphin|emacs|kate)|visual-studio-code" ]]; then
  11.         exec tmux -f "$XDG_CONFIG_HOME/tmux/tmux.conf"
  12.     fi
  13. else
  14.     if [[ "$(</proc/$PPID/cmdline)" =~ "konsole" ]]; then
  15.         unset TMUX TMUX_PANE
  16.     fi
  17. fi
  18. #
  19.  
  20. #
  21. # --- Enable ZI
  22. typeset -A ZI
  23. export ZI[BIN_DIR]="${HOME}/.config/zsh/.zi/bin"
  24. source "${ZI[BIN_DIR]}/zi.zsh"
  25.  
  26. autoload -Uz _zi
  27. (( ${+_comps} )) && _comps[zi]=_zi
  28.  
  29. # Preset Proxy
  30. export ALL_PROXY=http://127.0.0.1:7890
  31.  
  32. # -- Options
  33.  
  34. autoload -U select-word-style
  35. select-word-style bash
  36.  
  37.  
  38.  
  39. # WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
  40.  
  41. # Terminfo
  42. export TERMINFO=/usr/share/terminfo
  43.  
  44.  
  45. SPROMPT="%B%F{yellow}zsh: correct '%R' be '%r' [nyae]?%f%b "
  46. export FZF_DEFAULT_OPTS='--color=bg+:23 -m --bind ctrl-space:toggle,pgup:preview-up,pgdn:preview-down'
  47.  
  48. # 直接输入路径即可跳转
  49. setopt auto_cd
  50. # 允许多次重定向
  51. setopt multios
  52. # 自动添加目录栈
  53. setopt auto_pushd
  54. setopt pushd_ignore_dups
  55. # 补全列表允许不同列宽
  56. setopt listpacked
  57. # 交互模式下使用注释
  58. setopt interactive_comments
  59. # RPROMPT 执行完命令后就消除, 便于复制
  60. setopt transient_rprompt
  61. # setopt 输出显示开关状态
  62. setopt ksh_option_print
  63. # 单引号中 '' 表示一个 '
  64. setopt rc_quotes
  65. # 增强 glob
  66. setopt extended_glob
  67. # 没有匹配时原样输出 glob 而不是报错
  68. setopt no_nomatch
  69. # 开启拼写检查
  70. setopt correct
  71.  
  72. # auto slash
  73. zstyle ':completion:*' special-dirs true
  74. setopt autoparamslash
  75.  
  76.  
  77. bindkey '^R' histdb-skim-widget
  78. export FZF_FINDER_EDITOR_BINDKEY="^T"
  79.  
  80. ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="underline"
  81. HISTDB_FILE=$ZDOTDIR/.histdb/zsh-history.db
  82.  
  83. _zsh_autosuggest_strategy_histdb_top() {
  84.     local query="
  85.        select commands.argv from history
  86.        left join commands on history.command_id = commands.rowid
  87.        left join places on history.place_id = places.rowid
  88.        where commands.argv LIKE '$(sql_escape $1)%'
  89.        group by commands.argv, places.dir
  90.        order by places.dir != '$(sql_escape $PWD)', count(*) desc
  91.        limit 1
  92.    "
  93.     suggestion=$(_histdb_query "$query")
  94. }
  95.  
  96.  
  97. ZSH_AUTOSUGGEST_STRATEGY=(histdb_top match_prev_cmd completion)
  98. # ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
  99. # ZSH_AUTOSUGGEST_USE_ASYNC=1
  100. # ZSH_AUTOSUGGEST_MANUAL_REBIND=1
  101. # ZSH_AUTOSUGGEST_COMPLETION_IGNORE='( |man |pikaur -S )*'
  102. # ZSH_AUTOSUGGEST_HISTORY_IGNORE='?(#c50,)'
  103.  
  104. ## --- for python-better-expections
  105. export FORCE_COLOR=1
  106.  
  107. zstyle ':fzf-tab:complete:_zlua:*' query-string input
  108. zstyle ':fzf-tab:complete:kill:argument-rest' fzf-preview 'ps --pid=$word -o cmd --no-headers -w -w'
  109. zstyle ':fzf-tab:complete:kill:argument-rest' fzf-flags '--preview-window=down:3:wrap'
  110. zstyle ':fzf-tab:complete:kill:*' popup-pad 0 3
  111. zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
  112. zstyle ':fzf-tab:complete:cd:*' popup-pad 30 0
  113. zstyle ":fzf-tab:*" fzf-flags --color=bg+:23
  114. zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
  115. zstyle ':fzf-tab:*' switch-group ',' '.'
  116. zstyle ":completion:*:git-checkout:*" sort false
  117. zstyle ':completion:*' file-sort modification
  118. zstyle ':completion:*:exa' sort false
  119. zstyle ':completion:files' sort false
  120. zstyle ':fzf-tab:*:*argument-rest*' popup-pad 100 0
  121. zstyle ':fzf-tab:*:*argument-rest*' fzf-preview
  122.  
  123. export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow'
  124.  
  125. # --- Plugins
  126.  
  127. zi wait="0" lucid light-mode for \
  128.     hlissner/zsh-autopair \
  129.     hchbaw/zce.zsh \
  130.     wfxr/forgit \
  131.     esc/conda-zsh-completion \
  132.     m42e/zsh-histdb-skim \
  133.  
  134. zi light-mode for \
  135.     as="program" atclone="rm -f ^(rgg|agv)" \
  136.         lilydjwg/search-and-view \
  137.     atclone="dircolors -b LS_COLORS > c.zsh" atpull='%atclone' pick='c.zsh' \
  138.         trapd00r/LS_COLORS \
  139.     src="etc/git-extras-completion.zsh" \
  140.         tj/git-extras
  141.  
  142. zi wait="1" lucid for \
  143.     OMZL::clipboard.zsh \
  144.     OMZL::git.zsh \
  145.     OMZP::systemd/systemd.plugin.zsh \
  146.     OMZP::git/git.plugin.zsh \
  147.     OMZP::extract \
  148.     OMZP::pip \
  149.  
  150. zi ice wait lucid has'fzf' pick'fzf-finder.plugin.zsh'
  151. zi light leophys/zsh-plugin-fzf-finder
  152.  
  153. zi ice mv=":cht.sh -> cht.sh" atclone="chmod +x cht.sh" as="program"
  154. zi snippet https://cht.sh/:cht.sh
  155.  
  156. zi ice mv=":zsh -> _cht" as="completion"
  157. zi snippet https://cheat.sh/:zsh
  158.  
  159. zi as="completion" for \
  160.     OMZP::docker/_docker \
  161.     OMZP::fd/_fd
  162.  
  163. zi ice as"program" pick"bin/git-fuzzy"
  164. zi light bigH/git-fuzzy
  165.  
  166. zi ice lucid wait as'completion' blockf
  167. zi light zchee/zsh-completions
  168.  
  169. zi ice lucid wait as'completion' blockf has'pandoc'
  170. zi light srijanshetty/zsh-pandoc-completion
  171.  
  172. zi light Aloxaf/fzf-tab
  173.  
  174. zi light larkery/zsh-histdb
  175. autoload -Uz add-zsh-hook
  176.  
  177. zi ice wait lucid atinit"ZI[COMPINIT_OPTS]=-C; zpcompinit; zpcdreplay"
  178. zi light z-shell/F-Sy-H
  179.  
  180. zi ice wait lucid atload"!_zsh_autosuggest_start"
  181. zi load zsh-users/zsh-autosuggestions
  182.  
  183. zi light softmoth/zsh-vim-mode
  184.  
  185. eval $(thefuck --alias)
  186.  
  187. # --- Path and Export
  188.  
  189. # Set Vars
  190. export EDITOR='nvim'
  191. export BROWSER='/usr/bin/firefox-nightly'
  192. # WM Java:
  193. #This is a common issue in a number of window managers. (DWM, Awesome, bspwm) Java does not play well with these window managers. There are two methods.  
  194. export _JAVA_AWT_WM_NONREPARENTING=1
  195. export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
  196.  
  197. NVM_INIT_SCRIPT="/usr/share/nvm/init-nvm.sh"
  198. if [[ -f "$NVM_INIT_SCRIPT" ]]; then
  199.     source "$NVM_INIT_SCRIPT" --no-use
  200. fi
  201.  
  202.  
  203. # Alias
  204. source $ZDOTDIR/alias.zsh
  205.  
  206. # PATH
  207.  
  208. # ==== conda initialize ====
  209. __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
  210. if [ $? -eq 0 ]; then
  211.     eval "$__conda_setup"
  212. else
  213.     if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
  214.         . "/opt/anaconda/etc/profile.d/conda.sh"
  215.     else
  216.         export PATH="/opt/anaconda/bin:$PATH"
  217.     fi
  218. fi
  219. unset __conda_setup
  220.  
  221. PATH=$HOME/.npm-global/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.local/share/gomodule/bin:$PATH
  222. PATH=/home/jczhang/.local/share/gem/ruby/3.0.0/bin:$PATH
  223. export GOPATH="/home/jczhang/.local/share/gomodule"
  224.  
  225. export RANGER_LOAD_DEFAULT_RC=false
  226.  
  227. # zmodload zsh/zprof
  228.  
  229. function chpwd() {
  230.     emulate -L zsh
  231.     exa -bh --icons
  232. }
  233.  
  234.  
  235. KEYTIMEOUT=1
  236.  
  237. autoload -U up-line-or-beginning-search
  238. autoload -U down-line-or-beginning-search
  239. zle -N up-line-or-beginning-search
  240. zle -N down-line-or-beginning-search
  241. bindkey "^[[A" up-line-or-beginning-search # Up
  242. bindkey "^[[B" down-line-or-beginning-search # Down
  243.  
  244.  
  245. # bindkey -M vicmd "^[[3~" delete-char  # delete deletes in normal
  246. # bindkey '^[d' kill-word  #alt-d
  247. # bindkey '^[[1;5D' backward-word
  248. # bindkey '^[[1;5C' forward-word
  249.  
  250. # --- Prompt: p10k
  251. source $ZDOTDIR/.p10k.zsh
  252. zi ice depth=1
  253. zi light romkatv/powerlevel10k
  254.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement