169 lines
6.3 KiB
Bash
169 lines
6.3 KiB
Bash
HISTFILE="$HOME/.zsh_history"
|
||
HISTSIZE=10000
|
||
SAVEHIST=10000
|
||
bindkey -v
|
||
bindkey -v
|
||
bindkey -M viins "^[[3~" delete-char
|
||
bindkey -M vicmd "^[[3~" delete-char
|
||
bindkey -M viins "^[[2~" overwrite-mode
|
||
bindkey -M vicmd "^[[2~" overwrite-mode
|
||
bindkey -M viins "^[[H" beginning-of-line
|
||
bindkey -M vicmd "^[[H" beginning-of-line
|
||
bindkey -M viins "^[[F" end-of-line
|
||
bindkey -M vicmd "^[[F" end-of-line
|
||
bindkey -M viins "^[[5~" history-search-backward
|
||
bindkey -M vicmd "^[[5~" history-search-backward
|
||
bindkey -M viins "^[[6~" history-search-forward
|
||
bindkey -M vicmd "^[[6~" history-search-forward
|
||
KEYTIMEOUT=1
|
||
setopt APPEND_HISTORY
|
||
setopt SHARE_HISTORY
|
||
setopt PROMPT_SUBST
|
||
autoload -U compinit
|
||
compinit
|
||
source <(fzf --zsh)
|
||
if [[ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
|
||
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||
fi
|
||
if [[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
|
||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||
fi
|
||
if [[ -f ~/.zsh/plugins/fzf-tab/fzf-tab.plugin.zsh ]]; then
|
||
source ~/.zsh/plugins/fzf-tab/fzf-tab.plugin.zsh
|
||
fi
|
||
if [[ -f ~/.zsh/plugins/fzf-tab-completion/zsh/fzf-tab-completion.plugin.zsh ]]; then
|
||
source ~/.zsh/plugins/fzf-tab-completion/zsh/fzf-tab-completion.plugin.zsh
|
||
fi
|
||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main cursor)
|
||
typeset -gA ZSH_HIGHLIGHT_STYLES
|
||
ZSH_HIGHLIGHT_STYLES[comment]='fg=#585b70'
|
||
ZSH_HIGHLIGHT_STYLES[alias]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[global-alias]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[function]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[command]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[precommand]='fg=#a6e3a1,italic'
|
||
ZSH_HIGHLIGHT_STYLES[autodirectory]='fg=#fab387,italic'
|
||
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=#fab387'
|
||
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=#fab387'
|
||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=#cba6f7'
|
||
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#a6e3a1'
|
||
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=#f38ba8'
|
||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter-unquoted]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]='fg=#f38ba8'
|
||
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=#f38ba8'
|
||
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]='fg=#f38ba8'
|
||
ZSH_HIGHLIGHT_STYLES[command-substitution-quoted]='fg=#f9e2af'
|
||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter-quoted]='fg=#f9e2af'
|
||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=#f9e2af'
|
||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument-unclosed]='fg=#eba0ac'
|
||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=#f9e2af'
|
||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument-unclosed]='fg=#eba0ac'
|
||
ZSH_HIGHLIGHT_STYLES[rc-quote]='fg=#f9e2af'
|
||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument-unclosed]='fg=#eba0ac'
|
||
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[assign]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[named-fd]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[numeric-fd]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#eba0ac'
|
||
ZSH_HIGHLIGHT_STYLES[path]='fg=#cdd6f4,underline'
|
||
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=#cdd6f4,underline'
|
||
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]='fg=#f38ba8,underline'
|
||
ZSH_HIGHLIGHT_STYLES[globbing]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=#cba6f7'
|
||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-unclosed]='fg=#eba0ac'
|
||
ZSH_HIGHLIGHT_STYLES[redirection]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[arg0]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[default]='fg=#cdd6f4'
|
||
ZSH_HIGHLIGHT_STYLES[cursor]='fg=#cdd6f4'
|
||
zstyle ':fzf-tab:*' fzf-flags \
|
||
--color=bg+:#313244,bg:#1E1E2E,spinner:#F5E0DC,hl:#F38BA8 \
|
||
--color=fg:#CDD6F4,header:#F38BA8,info:#CBA6F7,pointer:#F5E0DC \
|
||
--color=marker:#B4BEFE,fg+:#CDD6F4,prompt:#CBA6F7,hl+:#F38BA8 \
|
||
--color=selected-bg:#45475A \
|
||
--color=border:#6C7086,label:#CDD6F4
|
||
export FZF_DEFAULT_OPTS=" \
|
||
--color=bg+:#313244,bg:#1E1E2E,spinner:#F5E0DC,hl:#F38BA8 \
|
||
--color=fg:#CDD6F4,header:#F38BA8,info:#CBA6F7,pointer:#F5E0DC \
|
||
--color=marker:#B4BEFE,fg+:#CDD6F4,prompt:#CBA6F7,hl+:#F38BA8 \
|
||
--color=selected-bg:#45475A \
|
||
--color=border:#6C7086,label:#CDD6F4"
|
||
prompt_symbol() {
|
||
if [[ "$KEYMAP" == "vicmd" ]]; then
|
||
print -r -- "%F{#ebcb8b}❮%f"
|
||
else
|
||
print -r -- "%F{#88c0d0}❯%f"
|
||
fi
|
||
}
|
||
update_vim_prompt() {
|
||
zle reset-prompt
|
||
}
|
||
zle-keymap-select() {
|
||
update_vim_prompt
|
||
}
|
||
zle-line-init() {
|
||
zle -K viins
|
||
update_vim_prompt
|
||
}
|
||
git_prompt_info() {
|
||
local branch
|
||
local staged
|
||
local modified
|
||
local untracked
|
||
local deleted
|
||
local conflicts
|
||
local git_state=""
|
||
branch=$(git branch --show-current 2>/dev/null)
|
||
if [[ -z "$branch" ]]; then
|
||
return
|
||
fi
|
||
staged=$(git diff --cached --name-only 2>/dev/null | wc -l | tr -d ' ')
|
||
modified=$(git diff --name-only 2>/dev/null | wc -l | tr -d ' ')
|
||
untracked=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d ' ')
|
||
deleted=$(git diff --name-only --diff-filter=D 2>/dev/null | wc -l | tr -d ' ')
|
||
conflicts=$(git diff --name-only --diff-filter=U 2>/dev/null | wc -l | tr -d ' ')
|
||
if (( staged > 0 )); then
|
||
git_state+=" %F{#b48ead} ${staged}%f"
|
||
fi
|
||
if (( modified > 0 )); then
|
||
git_state+=" %F{#ebcb8b} ${modified}%f"
|
||
fi
|
||
if (( untracked > 0 )); then
|
||
git_state+=" %F{#a3be8c} ${untracked}%f"
|
||
fi
|
||
if (( deleted > 0 )); then
|
||
git_state+=" %F{#d08770} ${deleted}%f"
|
||
fi
|
||
if (( conflicts > 0 )); then
|
||
git_state+=" %F{#bf616a} ${conflicts}%f"
|
||
fi
|
||
if [[ -n "$git_state" ]]; then
|
||
git_state=" %F{#88c0d0}❯%f${git_state}"
|
||
fi
|
||
print -r -- " %F{#88c0d0}❯%f %F{#8fbcbb} ${branch}%f${git_state}"
|
||
}
|
||
precmd() {
|
||
local exit_code=$?
|
||
if (( exit_code != 0 )); then
|
||
PROMPT_EXIT="%F{#941703}✗${exit_code}%f "
|
||
else
|
||
PROMPT_EXIT=""
|
||
fi
|
||
}
|
||
nvim() {
|
||
printf '\033]0;nvim\007'
|
||
command nvim "$@"
|
||
printf '\033]0;foot\007'
|
||
}
|
||
zle -N zle-keymap-select
|
||
zle -N zle-line-init
|
||
vi() { nvim "$@"; }
|
||
vim() { nvim "$@"; }
|
||
PROMPT='%F{#eceff4}%~%f$(git_prompt_info) $(prompt_symbol) '
|
||
alias rmpc='printf "\033]0;rmpc\007"; command rmpc; printf "\033]0;foot\007"'
|