-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdot_zshrc
More file actions
184 lines (149 loc) · 3.93 KB
/
Copy pathdot_zshrc
File metadata and controls
184 lines (149 loc) · 3.93 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
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
# Homebrew import
eval "$(/opt/homebrew/bin/brew shellenv)"
# Find Python binary directories
bins=$(
find "$HOME/Library/Python" -maxdepth 2 -type d -name 'bin' \
| tr '\n' ':' \
| sed 's/:$//'
)
export PATH="$PATH:$bins"
# Add chezmoi
# https://stackoverflow.com/a/18077919
path+=("$HOME/.bin")
path+=("$HOME/bin")
export PATH
path+=("$HOME/.config/emacs/bin")
export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/lib/gcc/current
# Initialize zsh completion system before any evals that use compdef
autoload -Uz compinit && compinit
#---- START oh-my-posh
export VIRTUAL_ENV_DISABLE_PROMPT=1
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
eval "$(oh-my-posh init zsh --config ~/.nheer.omp.yaml)"
#---- END oh-my-posh
# Created by `pipx`
export PATH="$PATH:/Users/nheer/.local/bin"
# zoxide https://github.com/ajeetdsouza/zoxide
eval "$(zoxide init zsh)"
# atuin https://docs.atuin.sh/guide/installation/
eval "$(atuin init zsh)"
# wtp shell integration (completion + hook)
if command -v wtp >/dev/null 2>&1; then
eval "$(wtp shell-init zsh)"
fi
np() {
local cd_file
cd_file="$(mktemp -t np-cd.XXXXXX)" || return 1
NP_CD_FILE="$cd_file" command np "$@"
local exit_code=$?
if [[ -f "$cd_file" ]]; then
local destination
destination="$(<"$cd_file")"
rm -f "$cd_file"
if [[ $exit_code -eq 0 && -n "$destination" && -d "$destination" ]]; then
cd "$destination" || return $exit_code
fi
fi
return $exit_code
}
alias newproj='np new'
alias graduateproj='np promote'
alias ai='codex --dangerously-bypass-approvals-and-sandbox'
__nht_resolve_command() {
command bun run "$HOME/bin/dev-tools/src/register.ts" --resolve "$1"
}
__nht_apply_action_file() {
local action_file="$1"
local exit_code="$2"
if [[ ! -f "$action_file" ]]; then
return "$exit_code"
fi
local action_line
action_line="$(<"$action_file")"
rm -f "$action_file"
if [[ "$exit_code" -ne 0 || -z "$action_line" ]]; then
return "$exit_code"
fi
local -a parts
parts=("${(@ps:\t:)action_line}")
local action="${parts[1]}"
case "$action" in
cd)
local value="${parts[2]}"
if [[ -n "$value" && -d "$value" ]]; then
cd "$value" || return 1
return 0
fi
;;
print)
printf '%s\n' "${(j:\t:)parts[2,-1]}"
return 0
;;
open)
local value="${parts[2]}"
if [[ -n "$value" ]]; then
command open "$value"
return $?
fi
;;
exec)
if [[ ${#parts[@]} -ge 2 ]]; then
"${parts[2]}" "${parts[@]:3}"
return $?
fi
;;
*)
printf 'Unsupported nht shell action: %s\n' "$action" >&2
return 1
;;
esac
return "$exit_code"
}
repo() {
local action_file
action_file="$(mktemp -t nht-action.XXXXXX)" || return 1
export NHT_ACTION_FILE="$action_file"
command bun run "$HOME/bin/dev-tools/src/repo/index.ts" "$@"
local exit_code=$?
unset NHT_ACTION_FILE
__nht_apply_action_file "$action_file" "$exit_code"
return $?
}
# television shell integration https://alexpasmantier.github.io/television/docs/Users/shell-integration/
if command -v tv >/dev/null 2>&1; then
eval "$(tv init zsh)"
fi
nht() {
local selection
local exit_code
if [[ $# -gt 0 ]]; then
selection="$(__nht_resolve_command "$1")"
exit_code=$?
shift
else
selection="$(tv nht --inline)"
exit_code=$?
fi
if [[ $exit_code -ne 0 || -z "$selection" ]]; then
return $exit_code
fi
local action_file
action_file="$(mktemp -t nht-action.XXXXXX)" || return 1
export NHT_ACTION_FILE="$action_file"
if [[ $# -gt 0 ]]; then
local quoted_args
printf -v quoted_args '%q ' "$@"
quoted_args="${quoted_args% }"
eval "$selection $quoted_args"
else
eval "$selection"
fi
exit_code=$?
unset NHT_ACTION_FILE
__nht_apply_action_file "$action_file" "$exit_code"
return $?
}
export PATH="$HOME/.bun/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
export EDITOR="nvim"
export VISUAL="nvim"