-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
87 lines (69 loc) · 2.15 KB
/
.zshrc
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
. $HOME/.bashrc
. $HOME/.zsh/git-prompt
. $HOME/.zsh/fzf.zsh
alias sz='source ~/.zshrc'
# Set command prompt and truncate username
PS1='%F{yellow}%4>>%n%<<%f%F{blue}@%f%F{red}%m%f %B%1~%b %B%F{blue}>%f%b '
# Git prompt
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWCOLORHINTS=1
precmd () { RPROMPT=$(__git_ps1 " (%s)") }
# Keep track of history
export HISTSIZE=10000
export SAVEHIST=10000
export HISTFILE=$HOME/.cache/zsh/history
# Automatically cd into typed directory
setopt autocd
# Autocomplete with tab support
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files
# Use vim keys in tab complete menu
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
# https://github.com/spaceship-prompt/spaceship-prompt/issues/91
bindkey "^?" backward-delete-char
# Quickly switch between vi modes
export KEYTIMEOUT=1
# fzf bindings
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
bindkey -s '^p' 'fzf-wrapper\n'
# nvim bindings
# Open fugitive
bindkey -s '^g' 'echo "" | nvim - +"0G"\n'
# Change the cursor depending on the vi mode
# Vim control sequences: https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html
cursorBlock='\e[2 q'
cursorVertLine='\e[6 q'
zle-line-init() {
echo -ne $cursorVertLine
}
zle -N zle-line-init
zle-keymap-select() {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne $cursorBlock
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne $cursorVertLine
fi
}
zle -N zle-keymap-select
# Edit current line in $EDITOR
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line
bindkey -M vicmd '^e' edit-command-line
# Directory stack
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
alias ds='dirs -v'
for index ({1..9}) alias "$index"="cd +${index}"; unset index
. $HOME/.zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
. $HOME/.zsh/plugins/zsh-bd/bd.zsh