Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Zsh config, managed by ZI
- # Author: JC Zhang <[email protected]>
- if [[ -r "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
- source "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh"
- fi
- # --- Auto start Tmux else in embedded mode
- if [[ -z $TMUX && $- == *i* ]]; then
- if [[ ! "$(</proc/$PPID/cmdline)" =~ "/usr/bin/(dolphin|emacs|kate)|visual-studio-code" ]]; then
- exec tmux -f "$XDG_CONFIG_HOME/tmux/tmux.conf"
- fi
- else
- if [[ "$(</proc/$PPID/cmdline)" =~ "konsole" ]]; then
- unset TMUX TMUX_PANE
- fi
- fi
- #
- #
- # --- Enable ZI
- typeset -A ZI
- export ZI[BIN_DIR]="${HOME}/.config/zsh/.zi/bin"
- source "${ZI[BIN_DIR]}/zi.zsh"
- autoload -Uz _zi
- (( ${+_comps} )) && _comps[zi]=_zi
- # Preset Proxy
- export ALL_PROXY=http://127.0.0.1:7890
- # -- Options
- autoload -U select-word-style
- select-word-style bash
- # WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
- # Terminfo
- export TERMINFO=/usr/share/terminfo
- SPROMPT="%B%F{yellow}zsh: correct '%R' be '%r' [nyae]?%f%b "
- export FZF_DEFAULT_OPTS='--color=bg+:23 -m --bind ctrl-space:toggle,pgup:preview-up,pgdn:preview-down'
- # 直接输入路径即可跳转
- setopt auto_cd
- # 允许多次重定向
- setopt multios
- # 自动添加目录栈
- setopt auto_pushd
- setopt pushd_ignore_dups
- # 补全列表允许不同列宽
- setopt listpacked
- # 交互模式下使用注释
- setopt interactive_comments
- # RPROMPT 执行完命令后就消除, 便于复制
- setopt transient_rprompt
- # setopt 输出显示开关状态
- setopt ksh_option_print
- # 单引号中 '' 表示一个 '
- setopt rc_quotes
- # 增强 glob
- setopt extended_glob
- # 没有匹配时原样输出 glob 而不是报错
- setopt no_nomatch
- # 开启拼写检查
- setopt correct
- # auto slash
- zstyle ':completion:*' special-dirs true
- setopt autoparamslash
- bindkey '^R' histdb-skim-widget
- export FZF_FINDER_EDITOR_BINDKEY="^T"
- ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="underline"
- HISTDB_FILE=$ZDOTDIR/.histdb/zsh-history.db
- _zsh_autosuggest_strategy_histdb_top() {
- local query="
- select commands.argv from history
- left join commands on history.command_id = commands.rowid
- left join places on history.place_id = places.rowid
- where commands.argv LIKE '$(sql_escape $1)%'
- group by commands.argv, places.dir
- order by places.dir != '$(sql_escape $PWD)', count(*) desc
- limit 1
- "
- suggestion=$(_histdb_query "$query")
- }
- ZSH_AUTOSUGGEST_STRATEGY=(histdb_top match_prev_cmd completion)
- # ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
- # ZSH_AUTOSUGGEST_USE_ASYNC=1
- # ZSH_AUTOSUGGEST_MANUAL_REBIND=1
- # ZSH_AUTOSUGGEST_COMPLETION_IGNORE='( |man |pikaur -S )*'
- # ZSH_AUTOSUGGEST_HISTORY_IGNORE='?(#c50,)'
- ## --- for python-better-expections
- export FORCE_COLOR=1
- zstyle ':fzf-tab:complete:_zlua:*' query-string input
- zstyle ':fzf-tab:complete:kill:argument-rest' fzf-preview 'ps --pid=$word -o cmd --no-headers -w -w'
- zstyle ':fzf-tab:complete:kill:argument-rest' fzf-flags '--preview-window=down:3:wrap'
- zstyle ':fzf-tab:complete:kill:*' popup-pad 0 3
- zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
- zstyle ':fzf-tab:complete:cd:*' popup-pad 30 0
- zstyle ":fzf-tab:*" fzf-flags --color=bg+:23
- zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
- zstyle ':fzf-tab:*' switch-group ',' '.'
- zstyle ":completion:*:git-checkout:*" sort false
- zstyle ':completion:*' file-sort modification
- zstyle ':completion:*:exa' sort false
- zstyle ':completion:files' sort false
- zstyle ':fzf-tab:*:*argument-rest*' popup-pad 100 0
- zstyle ':fzf-tab:*:*argument-rest*' fzf-preview
- export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow'
- # --- Plugins
- zi wait="0" lucid light-mode for \
- hlissner/zsh-autopair \
- hchbaw/zce.zsh \
- wfxr/forgit \
- esc/conda-zsh-completion \
- m42e/zsh-histdb-skim \
- zi light-mode for \
- as="program" atclone="rm -f ^(rgg|agv)" \
- lilydjwg/search-and-view \
- atclone="dircolors -b LS_COLORS > c.zsh" atpull='%atclone' pick='c.zsh' \
- trapd00r/LS_COLORS \
- src="etc/git-extras-completion.zsh" \
- tj/git-extras
- zi wait="1" lucid for \
- OMZL::clipboard.zsh \
- OMZL::git.zsh \
- OMZP::systemd/systemd.plugin.zsh \
- OMZP::git/git.plugin.zsh \
- OMZP::extract \
- OMZP::pip \
- zi ice wait lucid has'fzf' pick'fzf-finder.plugin.zsh'
- zi light leophys/zsh-plugin-fzf-finder
- zi ice mv=":cht.sh -> cht.sh" atclone="chmod +x cht.sh" as="program"
- zi snippet https://cht.sh/:cht.sh
- zi ice mv=":zsh -> _cht" as="completion"
- zi snippet https://cheat.sh/:zsh
- zi as="completion" for \
- OMZP::docker/_docker \
- OMZP::fd/_fd
- zi ice as"program" pick"bin/git-fuzzy"
- zi light bigH/git-fuzzy
- zi ice lucid wait as'completion' blockf
- zi light zchee/zsh-completions
- zi ice lucid wait as'completion' blockf has'pandoc'
- zi light srijanshetty/zsh-pandoc-completion
- zi light Aloxaf/fzf-tab
- zi light larkery/zsh-histdb
- autoload -Uz add-zsh-hook
- zi ice wait lucid atinit"ZI[COMPINIT_OPTS]=-C; zpcompinit; zpcdreplay"
- zi light z-shell/F-Sy-H
- zi ice wait lucid atload"!_zsh_autosuggest_start"
- zi load zsh-users/zsh-autosuggestions
- zi light softmoth/zsh-vim-mode
- eval $(thefuck --alias)
- # --- Path and Export
- # Set Vars
- export EDITOR='nvim'
- export BROWSER='/usr/bin/firefox-nightly'
- # WM Java:
- #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.
- export _JAVA_AWT_WM_NONREPARENTING=1
- export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
- NVM_INIT_SCRIPT="/usr/share/nvm/init-nvm.sh"
- if [[ -f "$NVM_INIT_SCRIPT" ]]; then
- source "$NVM_INIT_SCRIPT" --no-use
- fi
- # Alias
- source $ZDOTDIR/alias.zsh
- # PATH
- # ==== conda initialize ====
- __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
- if [ $? -eq 0 ]; then
- eval "$__conda_setup"
- else
- if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
- . "/opt/anaconda/etc/profile.d/conda.sh"
- else
- export PATH="/opt/anaconda/bin:$PATH"
- fi
- fi
- unset __conda_setup
- PATH=$HOME/.npm-global/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.local/share/gomodule/bin:$PATH
- PATH=/home/jczhang/.local/share/gem/ruby/3.0.0/bin:$PATH
- export GOPATH="/home/jczhang/.local/share/gomodule"
- export RANGER_LOAD_DEFAULT_RC=false
- # zmodload zsh/zprof
- function chpwd() {
- emulate -L zsh
- exa -bh --icons
- }
- KEYTIMEOUT=1
- autoload -U up-line-or-beginning-search
- autoload -U down-line-or-beginning-search
- zle -N up-line-or-beginning-search
- zle -N down-line-or-beginning-search
- bindkey "^[[A" up-line-or-beginning-search # Up
- bindkey "^[[B" down-line-or-beginning-search # Down
- # bindkey -M vicmd "^[[3~" delete-char # delete deletes in normal
- # bindkey '^[d' kill-word #alt-d
- # bindkey '^[[1;5D' backward-word
- # bindkey '^[[1;5C' forward-word
- # --- Prompt: p10k
- source $ZDOTDIR/.p10k.zsh
- zi ice depth=1
- zi light romkatv/powerlevel10k
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement