summaryrefslogtreecommitdiff
path: root/zsh/zshrc
blob: 9acd42f2c11ea36ca15c97d4e5beb019fcd5cc4d (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
#zmodload zsh/zprof
if [ -d "$HOME/.zplug" ]; then
  export ZPLUG_INSTALLED="y"
  source "$HOME/.zplug/init.zsh"
fi
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"

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 ~/.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

MYPROMPT=$'%S%F{002}[%n@%m]\UE0B2%F{015}%s%~%S%F{002}\UE0B0%#%s\UE0B0%f '
function zle-line-init zle-keymap-select {
  VIM_PROMPT=$'%S%F{012}[%n@%m]\UE0B2%F{015}%s%~%S%F{012}\UE0B0%#%s\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/zfunc"

if [ -n "$ZPLUG_INSTALLED" ]; then
  # zsh history substring search
  zplug "zsh-users/zsh-history-substring-search", as:plugin
  
  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
  
  # zsh syntax highlighting
  zplug "zsh-users/zsh-syntax-highlighting", defer:2
  
  # load zsh plugins
  zplug load
fi

autoload -Uz compinit
compinit

#zprof