-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_zshrc
More file actions
109 lines (88 loc) · 2.5 KB
/
dot_zshrc
File metadata and controls
109 lines (88 loc) · 2.5 KB
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
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# direnv
eval "$(direnv hook zsh)"
# ensure compatibility tmux <-> direnv
if [ -n "$TMUX" ] && [ -n "$DIRENV_DIR" ]; then
direnv reload
fi
# allow extended modifier keys in tmux
if [ -n "$TMUX" ]; then
precmd() { printf '\033[>4;1m' }
fi
# aliases
if [ -f ~/.aliases ]; then
. ~/.aliases
fi
# Save command history
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
# zsh-autosuggestions
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# this is the ctrl-enter binding
# bindkey '3;5u' autosuggest-accept
# # for some reason tmux swallows the 3
# bindkey ';5u' autosuggest-accept
# bindkey ';5;13~' autosuggest-accept
bindkey -M viins '^[[27;5;13~' autosuggest-accept
# fzf
source <(fzf --zsh)
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
_fzf_compgen_path() {
fd "$1"
}
_fzf_compgen_dir() {
fd --type=d "$1"
}
_fzf_comprun() {
local command=$1
shift
case "$command" in
cd) fzf --preview 'tree -C {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview 'bat -n --color=always {}' "$@" ;;
esac
}
# zoxide
eval "$(zoxide init zsh)"
# starship
eval "$(starship init zsh)"
# fzf-sesh
source ~/.local/share/fzf-sesh/bin/fzf-sesh
export PATH=$PATH:$HOME/.local/share/fzf-sesh/bin
# git using fugitive
git() {
if [[ -z "$1" ]]; then
# check if we are in a git repo
if ! git rev-parse --is-inside-work-tree 1> /dev/null; then
return 1
fi
command nvim -c :G
else
command git "$@"
fi
}
# ripgrep
export RIPGREP_CONFIG_PATH="$HOME/.config/ripgrep/config"
# zsh-vi-mode
function zvm_config() {
ZVM_VI_INSERT_ESCAPE_BINDKEY=jk
}
source $(brew --prefix)/opt/zsh-vi-mode/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
function zvm_after_lazy_keybindings() {
zvm_bindkey vicmd ' l' vi-end-of-line
zvm_bindkey vicmd ' h' vi-beginning-of-line
}
function zvm_after_init() {
source <(fzf --zsh)
}
export PATH=$PATH:$HOME/.local/bin
# start tmux if not already running
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then
sesh connect .
fi