summaryrefslogtreecommitdiff
path: root/zsh/.zshrc
blob: 29767b4e874cc095e2cf72b78deb10c014d63555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#zmodload zsh/zprof
[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
HISTFILE="$XDG_CONFIG_HOME/zsh/hist"
SAVEHIST=1000
HISTSIZE=1000
setopt APPEND_HISTORY
setopt HIST_FIND_NO_DUPS
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_VERIFY
setopt HIST_IGNORE_DUPS
setopt INC_APPEND_HISTORY
setopt HIST_REDUCE_BLANKS
setopt COMPLETE_ALIASES
setopt AUTO_CD

_SH="zsh"

fpath=("$XDG_CONFIG_HOME"/zsh/functions(:A) $fpath)
autoload -Uz anonsh

if [ -f "$XDG_CONFIG_HOME"/sh/aliases ]; then
  source "$XDG_CONFIG_HOME"/sh/aliases
fi
if [ -f "$XDG_CONFIG_HOME"/sh/functions ]; then
  source "$XDG_CONFIG_HOME"/sh/functions
fi

if [ -f "$XDG_CONFIG_HOME/zsh/zshrc" ]; then
  alias e='source "$XDG_CONFIG_HOME/zsh/zshrc"'
elif [ -f "$XDG_CONFIG_HOME/zshrc" ]; then
  alias e='source "$XDG_CONFIG_HOME/zshrc"'
elif [ -f "$HOME"/.zshrc ]; then
  alias e='source ~/.zshrc'
fi

source ~/.config/zsh/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE}

#autoload zkbd; zkbd
bindkey -v
bindkey "${key[Backspace]}" backward-delete-char
bindkey "${key[Delete]}" delete-char
bindkey "${key[Home]}" beginning-of-line
bindkey "${key[End]}" end-of-line
bindkey "${key[PageUp]}" history-substring-search-up
bindkey "${key[PageDown]}" history-substring-search-down

[ -f "$ZDOTDIR/.zsh_theme" ] && . "$ZDOTDIR/.zsh_theme"
COLOR1="${COLOR1:-002}"
COLOR2="${COLOR2:-006}"
COLORV="${COLORV:-012}"

if (env | grep -Fq 'DISTROBOX'); then
  MYPROMPT=$'%F{000}%K{004}[%n@%m]%F{013}\UE0B2%K{013}%F{000}%~%F{013}%K{004}\UE0B0%F{000}%#%F{004}%k\UE0B0%f '
else
  MYPROMPT=$'%F{000}%K{'"$COLOR1"$'}[%n@%m]%F{'"$COLOR2"$'}\UE0B2%K{'"$COLOR2"$'}%F{000}%~%F{'"$COLOR2"$'}%K{'"$COLOR1"$'}\UE0B0%F{000}%#%F{'"$COLOR1"$'}%k\UE0B0%f '
fi
function zle-line-init zle-keymap-select {
  VIM_PROMPT=$'%F{000}%K{'"$COLORV"$'}[%n@%m]%F{'"$COLOR2"$'}\UE0B2%K{'"$COLOR2"$'}%F{000}%~%F{'"$COLOR2"$'}%K{'"$COLORV"$'}\UE0B0%F{000}%#%F{'"$COLORV"$'}%k\UE0B0%f '
  PS1="${${KEYMAP/vicmd/$VIM_PROMPT}/main/$MYPROMPT}"
  zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select
export KEYTIMEOUT=1

fpath+="$XDG_CONFIG_HOME/zsh/functions"

autoload -Uz anonsh

autoload -Uz compinit 
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
  compinit
else
	compinit -C
fi

zshcache_time="$(date +%s%N)"

autoload -Uz add-zsh-hook

rehash_precmd() {
  if [[ -a /var/cache/zsh/pacman ]]; then
    local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)"
    if (( zshcache_time < paccache_time )); then
      rehash
      zshcache_time="$paccache_time"
    fi
  fi
}

add-zsh-hook -Uz precmd rehash_precmd

zstyle ':completion:*' hosts off

### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
    print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
    command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
    command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
        print -P "%F{33} %F{34}Installation successful.%f%b" || \
        print -P "%F{160} The clone has failed.%f%b"
fi

source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
    zdharma-continuum/zinit-annex-as-monitor \
    zdharma-continuum/zinit-annex-bin-gem-node \
    zdharma-continuum/zinit-annex-patch-dl \
    zdharma-continuum/zinit-annex-rust

### End of Zinit's installer chunk
zinit snippet OMZ::plugins/git/git.plugin.zsh

zinit load 'zsh-users/zsh-history-substring-search'
zinit ice wait atload'_history_substring_search_config'

bindkey "${key[Up]}" history-substring-search-up
bindkey "${key[Down]}" history-substring-search-down
bindkey -M vicmd "${key[Up]}" history-substring-search-up
bindkey -M vicmd "${key[Down]}" history-substring-search-down
bindkey -M vicmd "k" history-substring-search-up
bindkey -M vicmd "j" history-substring-search-down

#source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
zinit light 'zsh-users/zsh-syntax-highlighting'
zinit ice wait atload'_history_substring_search_config'
#zprof