-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
41 lines (33 loc) · 1.29 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
# Set Homebrew path
HOMEBREW_PREFIX="/opt/homebrew"
export PATH="$HOMEBREW_PREFIX/bin:$PATH"
# Set local bin path
LOCAL_BIN="$HOME/.local/bin"
export PATH="$LOCAL_BIN:$PATH"
# Function to conditionally execute a command if a certain path exists
try_exec() {
if [[ -e $1 ]]; then
eval $2
fi
}
# Initialize starship prompt if available
try_exec "$(command -v starship)" "$(starship init zsh)"
# Source asdf if available
try_exec "$HOMEBREW_PREFIX/opt/asdf/libexec/asdf.sh" "source $HOMEBREW_PREFIX/opt/asdf/libexec/asdf.sh"
# Plugins path
PLUGIN_PATH="$HOME/.zsh/plugins"
# Source ZSH plugins if directory exists
if [ -d "$PLUGIN_PATH" ]; then
for plugin in zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search; do
try_exec "$PLUGIN_PATH/$plugin/$plugin.zsh" "source $PLUGIN_PATH/$plugin/$plugin.zsh"
done
# Setup keybindings for history substring search
try_exec "$PLUGIN_PATH/zsh-history-substring-search/zsh-history-substring-search.zsh" "
bindkey '^[[1;3A' history-substring-search-up
bindkey '^[[1;3B' history-substring-search-down
"
fi
# Load custom aliases
try_exec "$HOME/.zsh/aw.zsh" "source $HOME/.zsh/aw.zsh"
try_exec "$HOME/.zsh/gt.zsh" "source $HOME/.zsh/gt.zsh"
try_exec "$HOME/.zsh/c.zsh" "source $HOME/.zsh/c.zsh"