-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
164 lines (130 loc) · 5.14 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
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
fpath+=~/.zsh/functions
# The following lines were added by compinstall {{{
zstyle ':completion:*' completer _expand _complete _ignored
zstyle :compinstall filename '/home/dima/.zshrc'
autoload -Uz compinit
compinit
unsetopt beep
setopt extendedglob
# End of lines added by compinstall }}}
# History options {{{
HISTFILE=~/.config/.histfile
HISTSIZE=16777216
SAVEHIST=$HISTSIZE
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
# }}}
# Reuse basic config from .bashrc.
source ~/.bashrc
# Completion settings {{{
# Origin: .oh-my-zsh/lib/completion.zsh
WORDCHARS=''
# unsetopt flowcontrol
# setopt auto_menu
# setopt complete_in_word
setopt always_to_end
# bindkey -M menuselect '^o' accept-and-infer-next-history
# Highlight selected menu item
zstyle ':completion:*:*:*:*:*' menu select
# Case sensitive completion
# zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
# Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path /home/dima/.zsh/cache
# Set colors for completion
# Origin: .oh-my-zsh/lib/theme-and-appearance.zsh
if [[ -z "$LS_COLORS" ]]; then
(( $+commands[dircolors] )) && eval "$(dircolors -b)"
fi
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# Always update info about existing binaries
zstyle ':completion:*' rehash true
# }}}
# Keybindings {{{
# Origin: .oh-my-zsh/lib/key-bindings.zsh
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
# Make sure that the terminal is in application mode when zle is active, since
# only then values from $terminfo are valid
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init() {
echoti smkx
}
function zle-line-finish() {
echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish
fi
bindkey -e # Use emacs key bindings
bindkey '^r' history-incremental-search-backward
# start typing + [Up-Arrow] - fuzzy find history forward
if [[ "${terminfo[kcuu1]}" != "" ]]; then
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
# start typing + [Down-Arrow] - fuzzy find history backward
if [[ "${terminfo[kcud1]}" != "" ]]; then
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
fi
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
# }}}
# Autosuggestions plugin {{{
source ~/config/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=7'
bindkey '\C-u' autosuggest-accept
# }}}
# Set prompt {{{
# Origins:
# .oh-my-zsh/themes/gentoo.zsh-theme
# https://github.com/Parth/dotfiles/blob/master/zsh/prompt.sh
autoload -U colors && colors
setopt promptsubst
function prompt_char {
if [ $UID -eq 0 ]; then echo "#"; else echo $; fi
}
function get_prompt {
PROMPT=""
# Username
CAN_I_RUN_SUDO=$(sudo -n true 2>&1|grep "sudo"|wc -l)
if [ ${CAN_I_RUN_SUDO} -eq 0 ]
then
PROMPT="%{$fg_bold[red]%}%n%{$reset_color%} "
else
PROMPT="%(!.%{$fg_bold[red]%}.%{$fg_bold[green]%}%n)%{$reset_color%} "
fi
# Working directory
PROMPT+="%{$fg_bold[blue]%}%(!.%1~.%~)%{$reset_color%} "
# Status code
PROMPT+="%{$fg_bold[red]%}%(?..%? )%{$reset_color%}"
# $ / #
PROMPT+="%{$fg_bold[blue]%}%_$(prompt_char)%{$reset_color%} "
echo $PROMPT
}
PROMPT="\$(get_prompt)"
# }}}
# Less coloring {{{
export LESS=-R
export LESS_TERMCAP_mb=$'\e[1;31m' # begin bold
export LESS_TERMCAP_md=$'\e[1;33m' # begin blink
export LESS_TERMCAP_so=$(tput smso; tput setaf 8; tput setab 15; tput bold) # begin reverse video
export LESS_TERMCAP_us=$'\e[01;30m' # begin underline
export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink
export LESS_TERMCAP_se=$'\e[0m' # reset reverse video
export LESS_TERMCAP_ue=$'\e[0m' # reset underline
# }}}
# vim:fdm=marker:foldlevel=0