-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
89 lines (77 loc) · 2.15 KB
/
dot_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
source ~/.zplug/init.zsh
zplug 'zplug/zplug', hook-build:'zplug --self-manage'
zplug "zsh-users/zsh-syntax-highlighting", defer:2
zplug "zsh-users/zsh-history-substring-search"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-completions"
zplug "Meroje/zsh-rbenv"
zplug "sorin-ionescu/prezto"
zplug "ptavares/zsh-direnv"
zplug "docker/cli", use:"contrib/completion/zsh"
zplug "greymd/docker-zsh-completion"
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
# Then, source plugins and add commands to $PATH
zplug load --verbose
# Source Prezto.
[[ -f "$ZPLUG_REPOS/$_ZPLUG_PREZTO"/runcoms/zshrc ]] && source "$ZPLUG_REPOS/$_ZPLUG_PREZTO"/runcoms/zshrc
# Source .zshrc.mine
[[ -f ~/.zshrc.mine ]] && source ~/.zshrc.mine
# Key Bind
bindkey -v
# History
export HISTFILE=${HOME}/.zsh_history
export HISTSIZE=100000
export SAVEHIST=100000
setopt hist_ignore_dups
setopt hist_find_no_dups
setopt hist_reduce_blanks
setopt hist_no_store
setopt share_history
setopt hist_reduce_blanks
setopt hist_ignore_space
setopt extended_history
setopt hist_verify
# Directory
setopt auto_cd
setopt auto_pushd
# aliases
case "${OSTYPE}" in
freebsd*|darwin*)
alias ll="ls -alG"
alias ls="ls -G -w"
;;
linux*)
alias ll="ls -al --color"
alias ls="ls --color"
;;
esac
alias h-all="history -n 0"
alias h="history 0"
alias restart-bt="blueutil --power 0 && blueutil --power 1"
alias dkc="docker-compose"
compdef dkc="docker-compose"
# peco functions
function peco-history-selection() {
BUFFER=$(history 1 | sort -k1,1nr | perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\*?\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' | peco --query "$LBUFFER")
CURSOR=${#BUFFER}
zle reset-prompt
}
zle -N peco-history-selection
bindkey '^R' peco-history-selection
# peco + ghq
function peco-src () {
local selected_dir=$(ghq list -p | peco --prompt "❯" --query "$LBUFFER")
if [ -n "$selected_dir" ]; then
BUFFER="cd ${selected_dir}"
zle accept-line
fi
#zle clear-screen
}
zle -N peco-src
bindkey '^g' peco-src