-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc-root
100 lines (86 loc) · 2.41 KB
/
.zshrc-root
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
##################
# CONFIGURATIONS #
##################
# prompt
autoload -U colors && colors
PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[red]%}%m %{$fg[green]%}%~ %{$reset_color%}%# "
setopt INC_APPEND_HISTORY
setopt HIST_IGNORE_DUPS
setopt EXTENDED_HISTORY
HISTFILE=~/.zsh_history
SAVEHIST=10000
HISTSIZE=10000
# Completion
ZSH_DISABLE_COMPFIX=true
autoload -U compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' special-dirs true
zmodload zsh/complist
compinit
# Enable Ctrl-x-e to edit command line
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
# Include hidden files in autocomplete:
_comp_options+=(globdots)
# 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
bindkey -v '^?' backward-delete-char
# ZLE hooks for prompt's vi mode status
function zle-line-init zle-keymap-select {
# Change the cursor style depending on keymap mode.
case $KEYMAP {
vicmd)
printf '\e[0 q' # Box.
;;
viins|main)
printf '\e[6 q' # Vertical bar.
;;
}
}
zle -N zle-line-init
zle -N zle-keymap-select
#########
# ALIAS #
#########
# User defined aliases
unalias -a
alias vi="nvim"
alias vim="nvim"
alias ls='ls -h --color=auto --group-directories-first --sort=extension'
alias l='ls -l'
alias ll='ls -lA'
alias less='less -i'
alias grep='grep --color'
alias info='info --vi-keys'
alias cp='cp -i'
alias ra='ranger'
alias ssh='TERM=xterm-256color ssh'
alias cdiff='diff-so-fancy | less --tabs=4 -RFX'
#################
# FZF OVERWRITE #
#################
# Initialize fzf
[ -f /usr/share/fzf/key-bindings.zsh ] && source /usr/share/fzf/key-bindings.zsh
# https://github.com/junegunn/fzf/issues/1309
# Remove repeated entries from fzf history search
fzf-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail 2> /dev/null
selected=( $(fc -rl 1 |
sort -k2 -k1rn | uniq -f 1 | sort -r -n |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle reset-prompt
return $ret
}