-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
utilities.zsh
90 lines (70 loc) · 2.93 KB
/
utilities.zsh
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
#####################################################
### This is the OPTIONAL ZSH powerless utlity script.
###
### How to call: source utilities.zsh <ENABLE_DIRSTACK_TWEAKS>
#####################################################
### Shortcuts.
#####################################################
bindkey '^[[1;5D' backward-word # CTRL+LEFT - jump to previous word boundary
bindkey '^[[1;5C' forward-word # CTRL+RIGHT - jump to next word boundary
bindkey '^[[3~' delete-char # BACKSPACE - delete character before cursor
bindkey '^[3;5~' delete-char # DELETE - delete character after cursor
bindkey '^[[H' beginning-of-line # HOME - go to beginning of line
bindkey '^[[F' end-of-line # END - go to end of line
bindkey '^[[3;5~' kill-word # CTRL+DELETE - delete whole next word
bindkey '^[[1;5A' history-beginning-search-backward # History search
bindkey '^[[1;5B' history-beginning-search-forward # History search
case $(uname -s) in
*CYGWIN*) bindkey '^_' backward-kill-word ;; # CTRL+BACKSPACE - delete whole previous word.
*) bindkey '^H' backward-kill-word ;; # CTRL+BACKSPACE - delete whole previous word.
esac
### Options.
#####################################################
# Disable duplicate history entries.
setopt HIST_IGNORE_DUPS HIST_FIND_NO_DUPS HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS
# No beeping.
setopt NO_BEEP
# No need to type "cd".
setopt AUTO_CD
# Complete aliases.
setopt COMPLETE_ALIASES
# Do not remove slash when executed completed expression.
unsetopt AUTO_REMOVE_SLASH
### Dirstack and history.
#####################################################
if [[ $1 == true ]]; then
# Setup directory stack.
setopt AUTO_PUSHD PUSHD_SILENT PUSHD_TO_HOME PUSHD_IGNORE_DUPS PUSHD_MINUS
# Setup persistent directory stack.
DIRSTACKFILE="$HOME/.zdirstack"
DIRSTACKSIZE=30
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
[[ -d $dirstack[1] ]] && popd
fi
chpwd() {
print -l $PWD ${(u)dirstack} > $DIRSTACKFILE
}
alias s='cd -1 > /dev/null 2>&1' # Performs swap of two mest recent entries in dirstack.
fi
### Completions.
#####################################################
# Setup completions & menu selections.
autoload -U compinit
compinit
# General completions settings.
zstyle ':completion:*' verbose true
zstyle ':completion:*' menu select=5
zstyle ':completion:*' use-cache on
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' accept-exact-dirs true
zstyle ':completion:*' list-dirs-first true
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' completer _complete _approximate
# Approximate settings.
zstyle ':completion:*:approximate:*' max-errors 2 numeric
# Cd settings.
zstyle ':completion:*:cd:*' ignore-parents parent pwd
# Kill settings.
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:*:kill:*:jobs' verbose false