-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain
executable file
·177 lines (140 loc) · 5.55 KB
/
main
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env zsh
if [ -e "$HOME/.nix-profile/share/zsh/site-functions" ]; then
fpath+=("$HOME/.nix-profile/share/zsh/site-functions")
fi
if [ -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then
source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
fi
fpath=("$ZSH_CFG_ROOT/completion" $fpath)
autoload -U +X compinit && compinit -i
autoload -U +X bashcompinit && bashcompinit
# Usefull keep command (that I never use)
# autoload -U keeper && keeper
autoload -U zmv
alias zcp='zmv -C' zln='zmv -L'
setopt GLOB_COMPLETE
# setopt nobanghist
# disabled for preexec version
# function precmd() {
# if [ "$(id -u)" -ne 0 ]; then
# FULL_CMD_LOG="$HOME/.logs/zsh-history-$(date -u "+%Y-%m-%d").log"
# echo "$USER@`hostname`:`pwd` [$(date -u)] `\history -1`" >> ${FULL_CMD_LOG}
# fi
# }
function preexec() {
newLine="$1"
if [ "$(id -u)" -ne 0 ]; then
FULL_CMD_LOG="$HOME/.logs/zsh-history-$(date -u "+%Y-%m-%d").log"
echo "$USER@$(hostname):$(pwd) [$(date -u)] $newLine" >> ${FULL_CMD_LOG}
fi
}
# keep background processes at full speed
setopt NOBGNICE
# Ignore globbings that don't match anything
setopt NULL_GLOB
# Extended globbing
setopt EXTENDED_GLOB
# When use with urxvt backspace is correct
#stty erase "^H"
# vi functionality
setopt vi
bindkey -v
if false; then
# Setup new style completion system. To see examples of the old style (compctl
# based) programmable completion, check Misc/compctl-examples in the zsh
# distribution.
# Completion Styles
# list of completers to use (does not work correctly)
# TODO: figure out how to complete on redirect
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate _redirect
# zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
# allow one error for every three characters typed in approximate completer
zstyle -e ':completion:*:approximate:*' max-errors \
'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
# insert all expansions for expand completer
zstyle ':completion:*:expand:*' tag-order all-expansions
fi
if ! command -v fzf >/dev/null; then
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
fi
# displays a menu for tabbing around
zstyle ':completion:*' menu yes=long-list
zstyle ':completion:*' menu select=2
# zstyle ':completion:*:*:kill:*' command 'ps -u$USER -o pid,%cpu,tty,cputime,cmd'
# Most Massively Useful Option ever!
# protects you from "you shoot yourself in the foot".
setopt rm_star_wait
setopt auto_pushd pushd_ignore_dups pushd_minus pushd_silent
# history settings
HISTSIZE=1000000000
SAVEHIST=1000000000
HISTFILE=~/.zsh_history
# All running shells have the same history - always!
# setopt SHARE_HISTORY
# alternatively: load history via `fc -RI`
alias zr='fc -RI'
setopt EXTENDED_HISTORY
# No duplicates...
setopt HIST_IGNORE_DUPS
# Don't put commands starting with a space character into the history
setopt HIST_IGNORE_SPACE
# Append to history immediately
setopt INC_APPEND_HISTORY
# Do not write duplicates to history file
setopt HIST_IGNORE_ALL_DUPS
# short for loops containing just one command:
# for f (*.html) mv $f ${f:r}.php
setopt SHORT_LOOPS
# cd to directory just by giving it's name
setopt AUTO_CD
# This controls what the line editor considers a word. By default it
# includes '/', which makes it so that when I M-del (attempting to erase
# a directory in a path), I erase the whole path. Annoying.
# WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # (default)
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
export EDITOR="vim"
#######################
## User contributions #
#######################
# Remember recent directories beyond session and shell
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
add-zsh-hook -Uz zsh_directory_name zsh_directory_name_cdr
# completion for above
zstyle ':completion:*:*:cdr:*:*' menu selection
zstyle ':chpwd:*' recent-dirs-max 30
zstyle ':chpwd:*' recent-dirs-prune parent
# no fallback for unknown git commands
zstyle ':completion:*:*:git*:*' use-fallback false
if false; then
# 'ctrl-x r' will complete the 12 last modified (mtime) files/directories
zle -C newest-files complete-word _generic
bindkey '^B' newest-files
zstyle ':completion:newest-files:*' completer _files
zstyle ':completion:newest-files:*' file-patterns '*(omN[1,12])'
zstyle ':completion:newest-files:*' menu select yes
zstyle ':completion:newest-files:*' sort false
zstyle ':completion:newest-files:*' matcher-list 'b:=*' # important
fi
zstyle ':completion:*:processes' command 'ps -ax'
zstyle ':completion:*:processes-names' command 'ps -aeo comm='
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:*:killall:*:processes-names' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:*:killall:*' menu yes select
if false; then
zle -C complete-files complete-word _generic
zstyle ':completion:complete-files:*' completer _files
bindkey "^x^f" complete-files
fi
# vim: ft=zsh