-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
122 lines (92 loc) · 3.23 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
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
# +------------------------+
# | ZSH Configuration file |
# +------------------------+
# ---- EXPORTS ----------------------------------
export EDITOR=/usr/bin/nvim
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
# ---- HISTORY ----------------------------------
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
# ---- Completion -------------------------------
autoload -Uz compinit
zstyle ':completion:*' menu select
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
zmodload zsh/complist
compinit
_comp_options+=(globdots)
# ---- VI MODE CONFIG ---------------------------
## Activate vi mode.
bindkey -v
## Remove mode switching delay.
KEYTIMEOUT=5
## Change cursor shape for different vi modes.
zle-keymap-select() {
case $KEYMAP in
vicmd) echo -ne '\e[1 q';; # block
viins|main) echo -ne '\e[5 q';; # beam
esac
}
zle -N zle-keymap-select
zle-line-init() {
zle -K viins
echo -ne '\e[5 q'
}
zle -N zle-line-init
echo -ne '\e[5 q'
preexec() { echo -ne '\e[5 q' }
# ---- KEYBINDS ---------------------------------
## Emacs binding in insert mode
bindkey -M main '^P' up-line-or-history
bindkey -M main '^N' down-line-or-history
bindkey -M main '^B' backward-char
## Command buffer editing
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey -M main '^F' edit-command-line
bindkey -M menuselect '^F' forward-char
# ---- FUNCTIONS --------------------------------
## Same command but with extra features
function ls { eza --git --icons $@ }
function cat { bat --theme=gruvbox-dark $@ }
## Fuzzy finder utilities
function frm { fd --type=file | sk -m --preview 'file {}' | xargs -d '\n' rm }
function fcd { cd "$(fd --type=d | sk --preview 'eza {} --icons -la --color=always')" }
function fgd { cd $(dirname $(fd -H -g \*.git ~/*/) | sk --preview 'eza {} --git-ignore --icons -T --color=always') }
function fca { bat "$(fd --type=file | sk --preview='bat {} --theme=gruvbox-dark --color=always')" }
function fxo { xdg-open "$(fd --type=file | sk --preview 'file {}')" }
function frg { sk --ansi -ic "rg {} --color=always --line-number" }
## Quickly start a dev server
function sv { python -m http.server 3000 $@ }
## Pandoc settings mostly for compiling markdown
function mdc {
pandoc $@ \
-s --pdf-engine=xelatex \
-V "numbersections:true" \
-V "geometry:margin=30mm"
}
mkcd() { mkdir "$1" && cd "$1" }
cdtemp() { cd "$(mktemp -d)" }
# ---- ALIASES ----------------------------------
alias nv='nvim'
alias ll='ls -l'
alias la='ls -a'
alias lla='ls -la'
alias duh='du -h'
# ---- PROMPT -----------------------------------
autoload -Uz vcs_info
function precmd { vcs_info }
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' formats ' %b'
zstyle ':vcs_info:*' actionformats ' %b (%a)'
setopt prompt_subst
PROMPT='%F{blue}%~%f%F{magenta}${vcs_info_msg_0_}%f%(?..%F{red} %?%f) %(?:%F{green}❯ %f:%F{red}❯ %f)'
# ---- PLUGINS ----------------------------------
## Syntax highlighting
. /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
## Autocompletion (just to make tab completion more convenient)
. /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(completion)
# bindkey '^@' autosuggest-accept