-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_zshrc.tmpl
197 lines (159 loc) · 5.92 KB
/
dot_zshrc.tmpl
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{{ if eq .chezmoi.os "linux" }}
export PATH="$PATH:$HOME/bin"
export PATH="$PATH:$HOME/.fzf/bin"
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
if [ -z "$TMUX" ]; then
export TMUX_CONF="$HOME/.tmux.conf"
username=$(basename $HOME)
if command -v tmux >/dev/null 2>&1; then
exec env TMUX_TMPDIR=/tmp tmux -u2 -f "$TMUX_CONF" new-session -As "$username" -c "$HOME"
else
echo "tmux not found. Please install it via Homebrew or another package manager."
fi
fi
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Source Prezto
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Init zplug
if [[ ! -d ~/.zplug ]];then
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
fi
source ~/.zplug/init.zsh
# Select zplug plugins
zplug "agkozak/zsh-z"
zplug "junegunn/fzf"
zplug "yuhonas/zsh-aliases-lsd"
zplug "romkatv/powerlevel10k", as:theme, depth:1
# Make sure that plugins are installed
if ! zplug check --verbose; then
printf "Installing missing zplug plugins...\n"
zplug install
fi
# Load Zplug plugins
zplug load
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
{{else if eq .chezmoi.os "darwin" -}}
export PATH="$PATH:$HOME/bin"
export PATH="$PATH:$HOME/.fzf/bin"
export PATH="/opt/homebrew/bin:$PATH"
if [ -z "$TMUX" ]
then
export TMUX_CONF="$HOME/.tmux.conf"
username=$(basename $HOME)
if command -v tmux >/dev/null 2>&1; then
exec env TMUX_TMPDIR=/tmp tmux -u2 -f "$TMUX_CONF" new-session -As "$username" -c "$HOME"
else
echo "tmux not found. Please install it via Homebrew or another package manager."
fi
fi
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Source Prezto
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Init zplug
if [[ ! -d ~/.zplug ]];then
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
fi
source ~/.zplug/init.zsh
# Select zplug plugins
zplug "agkozak/zsh-z"
zplug "junegunn/fzf"
zplug "yuhonas/zsh-aliases-lsd"
zplug "romkatv/powerlevel10k", as:theme, depth:1
# Make sure that plugins are installed
if ! zplug check --verbose; then
printf "Installing missing zplug plugins...\n"
zplug install
fi
# Load Zplug plugins
zplug load
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
{{end -}}
tmux_jump() {
# starting in ~/code...
BASE="$HOME/code/github.com"
# ... look for directories exactly two levels deep (`~/code/owner/project`)
# and match them with fzf. In this case we break ties by favoring matches
# on the project name instead of the owner name (implementaion means
# favoring matches closer to the end of the string.) This is simplified a
# little bit with the `--select-1 --query="$1"` line: if there's only one
# match for the argument passed in as the first argument to this function,
# we select immediately instead of asking for an interactive selection.
SELECTED=$(find "$BASE" -mindepth 2 -maxdepth 2 -type d | sed "s|$BASE/||g" | fzf --tiebreak=end --select-1 --query="$1")
# fzf will exit with a non-zero code if you ctrl-c or ctrl-g out of
# it. We use this as a signal that we don't want to jump after all.
if [[ "$?" != 0 ]]; then echo "cancelling!"; return 1; fi
# call tmux-session on the *full* path to the matched project!
tmux-session "$BASE/$SELECTED"
}
# and alias this so I can just do `t bytes.zone` instead of having to type
# tmux_jump every time.
alias tj=tmux_jump
alias ts=tmux-session
export PYTHONBREAKPOINT="IPython.embed"
################################################################################
# put in vi mode:
################################################################################
bindkey -v
export EDITOR='nvim'
export VISUAL='nvim'
# add kj and jk to insert mode
bindkey -M viins 'kj' vi-cmd-mode
bindkey -M viins 'jk' vi-cmd-mode
bindkey '^p' history-beginning-search-backward
bindkey '^n' history-beginning-search-forward
# Change cursor shape for different vi modes.
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne '\e[5 q'
fi
}
if [ -f ~/.zshrc_local ]; then
source ~/.zshrc_local
fi
if [ -f ~/.profile ]; then
source ~/.profile
fi
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# aliases
# alias pomo='noti pomodoro --simple'
# alias dash='noti pomodoro --simple 5'
alias gg="lazygit"
alias chd='cd "$(chezmoi source-path)"'
alias cha="chezmoi apply"
alias ssh='TERM=xterm-256color \ssh'
setopt INC_APPEND_HISTORY
export NOTES_DIR="$HOME/notes"
export ZK_NOTEBOOK_DIR="$NOTES_DIR/.zk"
# Function to add Homebrew's Python to PATH
add_homebrew_to_path() {
# Get the Homebrew prefix
local brew_prefix="$(brew --prefix)"
if [[ -n "$brew_prefix" && -d "$brew_prefix/bin" && ":$PATH:" != *":$brew_prefix/bin:"* ]]; then
# Prepend Homebrew bin to PATH
PATH="$brew_prefix/bin:$PATH"
fi
export PATH
}
# Call the function to update PATH
add_homebrew_to_path