blob: 983cd4321b6f63eaa84bdc0dea9856be6bf715ad (
plain)
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
|
[[ -f "${ZDOTDIR:-$HOME}/.zprofile" ]] && source "${ZDOTDIR:-$HOME}/.zprofile"
[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return # for tramp
[[ "$(tty)" == "/dev/tty1" ]] && startx && return
HISTFILE=~/.histfile
HISTSIZE=5000
SAVEHIST=$HISTSIZE
KEYBOARD_HACK=" "
HISTORY_IGNORE=" *|*INSIDE_EMACS*"
TIMEFMT="%J
user %U
system %S
cpu %P
total %*E"
setopt nobeep
setopt emacs
setopt autocd
setopt auto_pushd
setopt auto_name_dirs
setopt rm_star_silent
setopt auto_resume
setopt auto_continue
setopt notify
setopt append_history
setopt share_history
setopt prompt_subst
stty stop undef
autoload -U compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' group-name ''
zmodload zsh/complist
compinit -d ~/.cache/zcompdump
replace() {
local REPLY
autoload -Uz read-from-minibuffer
read-from-minibuffer "Replace: "
local text=$REPLY
read-from-minibuffer "Replace $text with: "
local repl=$REPLY
RBUFFER="${BUFFER//$text/$repl}"
}
zle -N replace
fzfcd() {
cd "$(find -L . -mindepth 1 -path '*/.*' -prune -o -type d -print 2>/dev/null | cut -c3- | fzf)"
zle reset-prompt
}
zle -N fzfcd
fzff() {
local file=$(find -L . -mindepth 1 -path '*/.*' -prune -o -type f -print 2>/dev/null | cut -c3- | fzf)
BUFFER="$LBUFFER$file$RBUFFER"
CURSOR=$(($CURSOR + ${#file}))
zle reset-prompt
}
zle -N fzff
autoload -U select-word-style
select-word-style bash
bindkey -e
bindkey -M emacs "\C-\b" backward-kill-word
bindkey -M emacs "^[[1;5D" backward-word
bindkey -M emacs "^[Od" backward-word
bindkey -M emacs "^[^[[D" backward-word
bindkey -M emacs "^[[1;5C" forward-word
bindkey -M emacs "^[Oc" forward-word
bindkey -M emacs "^[^[[C" forward-word
bindkey -M emacs "^[%" replace
bindkey -M emacs "^Xd" fzfcd
bindkey -M emacs "^X^F" fzff
export EDITOR=e
export PAGER=less
_prompt_git_status() {
local branch="$(command git name-rev --name-only HEAD 2>/dev/null)"
local root="$(command git rev-parse --show-toplevel 2>/dev/null)"
# hack to ignore next condition if we're on master
[ "$branch" != "master" ] && root=""
if [ "$branch" -a "$root" != "$HOME" ]; then
_git_status=" %2F(on %4F$branch)%f"
else
_git_status=""
fi
}
precmd () {
_prompt_git_status
}
PROMPT="%B%f%4F%~%f\$_git_status %4F%(!,#,$)%b%f "
RPROMPT="%B%5F($USERNAME %1F@ %2F$(hostname))%b%f"
alias rm='rm -I'
alias mkdir='mkdir -p'
alias ls='ls --color=auto'
alias grep='grep --color=auto'
-() { cd - } # aliasing - doesn't work
alias '...'='cd ../..'
alias restart='exec zsh'
alias -g 'G'='| grep'
alias -g 'L'='| $PAGER'
[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && \
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f /usr/share/zsh/site-functions/zsh-syntax-highlighting.zsh ] && \
source /usr/share/zsh/site-functions/zsh-syntax-highlighting.zsh
[ -f ~/.zshrc.local ] && source ~/.zshrc.local
|