Repository navigation
Expand file tree
/
Copy path.bashrc.local
More file actions
250 lines (199 loc) · 6.79 KB
/
Copy path.bashrc.local
File metadata and controls
250 lines (199 loc) · 6.79 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
if [ -t 0 ]; then stty -ixon; fi
shopt -s globstar
parse_git_branch() { b=$(git branch --show-current 2> /dev/null); echo ${b:+" ($b)"}; }
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(parse_git_branch)\[\033[00m\]\$ '
[ -f ~/.bash_aliases ] && . ~/.bash_aliases
[ -f ~/.bash_secrets ] && . ~/.bash_secrets
alias config="/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME"
export VISUAL=vim
export EDITOR="$VISUAL"
export PERL_MM_USE_DEFAULT=1
export IGNOREEOF=2
export PAGER=less
export LESS=-XRi
export LANG='en_US.UTF-8'
export CLICOLOR=1
tarz () { tar -I pigz -cf $1.tgz $1; }
commit () { git commit -am "${1}"; git push; }
fixes () { git commit -am "fixes #${1}"; git push; }
git_clone_all () {
cd ~/git
parallel -a repos 'git clone git@github.com:fastai/{}.git'
cd -
}
git_pull_all () {
pushd ~/git
parallel -a repos 'echo " # {}" && cd ~/git/{} && git pull'
popd
}
git_status_rel () {
pushd ~/git
parallel -a releases 'echo " # {}" && cd ~/git/{} && git status'
popd
}
vibash () {
vim ~/.bashrc
. ~/.bashrc
}
vibashl () {
vim ~/.bashrc.local
. ~/.bashrc
}
eval "$(gh completion -s bash)"
# Vanilla MacOS, based on BSD, has a different `ls`. It uses -G instead
# of --color. The colors are also handled differently (dircolors is not
# available by default; uses different env vars for controlling colors).
#
# Previously depended on a conda environment with GNU coreutils
# installed so that we get the exact same colors as on Linux. That proved
# finicky. See [0] for some details. so this always uses the system `ls` on Mac, setting the colors to be
# close enough.
#
# The solution here is:
# - check $LS_COLORS (note underscore) in an environment with dircolors and GNU ls
# - paste the value of $LS_COLORS into [2]
# - copy the reported $LSCOLORS (no underscore) value. That will be used by BSD ls.
# - export LSCOLORS on Mac.
#
# [0] https://github.com/daler/dotfiles/pull/35
# [1] https://superuser.com/a/1746907
# [2] https://geoff.greer.fm/lscolors
#
if [[ $OSTYPE == darwin* ]]; then
export LSCOLORS=cxgxfxexbxegedabagacad
alias ls='/bin/ls -G'
else
if command -v dircolors > /dev/null; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi
alias ls="ls --color=auto"
fi
# Essential bash completion
if [ -x "$(command -v brew)" ]; then
if [ -f $(brew --prefix)/etc/bash_completion ]
then
source $(brew --prefix)/etc/bash_completion
fi
fi
# Fix Catalina zsh shit warning
export BASH_SILENCE_DEPRECATION_WARNING=1
if [ -d $HOME/.modular ]; then
export MODULAR_HOME="/Users/cvardema/.modular"
export PATH="/Users/cvardema/.modular/pkg/packages.modular.com_mojo/bin:$PATH"
fi
# Make sure that local bin is in path
#
export PATH="/Users/cvardema/.local/bin:$PATH"
# -------------------------------------------------------------------
# nbdev + uv helpers (2025-04-update)
# -------------------------------------------------------------------
export NBDEV_TEMPLATE_REPO="la3d/nbdev-template-cc" # template repo
export NBDEV_DEFAULT_VIS="--private" # default visibility
# ---- ALIASES -------------------------------------------------------
alias uv-sync="uv sync" # ✅ no arg needed
alias nb-prep="nbdev_export && nbdev_clean"
alias nb-test="nbdev_test && pytest -q"
alias nb-ci="nb-prep && nb-test"
alias nb-docs="nbdev_preview"
# ---- FUNCTIONS -----------------------------------------------------
nb-new () {
if [[ -z "$1" ]]; then
echo "Usage: nb-new <project-name> [-o org] [--public|--private|--internal] [extra gh flags...]"
return 1
fi
local PRJ="$1"; shift
local ORG=""; local VIS="$NBDEV_DEFAULT_VIS"; local GHFLAGS=()
while (( "$#" )); do
case "$1" in
-o|--org) ORG="$2"; shift 2 ;;
--public|--private|--internal) VIS="$1"; shift ;;
*) GHFLAGS+=("$1"); shift ;;
esac
done
local TARGET_REPO="${ORG:+$ORG/}$PRJ"
echo "🚀 Creating & cloning $TARGET_REPO from $NBDEV_TEMPLATE_REPO ($VIS)…"
gh repo create "$TARGET_REPO" \
--template "$NBDEV_TEMPLATE_REPO" \
"$VIS" -c -y "${GHFLAGS[@]}" || return 1 # -c==--clone, -y skips prompt
cd "$PRJ" || return 1
echo "📦 Syncing dev environment with uv…"
uv-sync || return 1
echo "📝 Generating nbdev settings.ini…"
nbdev_create_config --repo "$TARGET_REPO" \
--author "$(git config user.name)" \
--description "$PRJ library"
git add .
git commit -m "Initial nbdev scaffolding"
git push -u origin main
echo "✅ Project $TARGET_REPO ready!"
}
# run the whole pipeline locally
nb-runall () { uv-sync && nb-ci; }
# -------------------------------------------------------------------
# uvws workspace helpers
# -------------------------------------------------------------------
# Activate uvws on shell startup if it exists
if [ -f "$HOME/uvws/.venv/bin/activate" ]; then
source "$HOME/uvws/.venv/bin/activate"
fi
# Switch to uvws workspace mode
ws () {
if [ ! -f "$HOME/uvws/.venv/bin/activate" ]; then
echo "❌ uvws not found at ~/uvws"
echo " Clone it with: cd ~ && git clone git@github.com:charlesvardeman/uvws.git && cd uvws && uv sync"
return 1
fi
# Deactivate current venv if active
if command -v deactivate &> /dev/null; then
deactivate
fi
source "$HOME/uvws/.venv/bin/activate"
echo "✅ Switched to uvws workspace mode"
}
# Switch to local .venv mode
lv () {
if [ ! -f ".venv/bin/activate" ]; then
echo "❌ No .venv found in current directory"
return 1
fi
# Deactivate current venv if active
if command -v deactivate &> /dev/null; then
deactivate
fi
source .venv/bin/activate
echo "✅ Switched to local .venv mode"
}
# Add package(s) to uvws workspace and commit
ws-add () {
if [ -z "$1" ]; then
echo "Usage: ws-add <package> [package2 ...]"
return 1
fi
if [ ! -d "$HOME/uvws" ]; then
echo "❌ uvws not found at ~/uvws"
return 1
fi
pushd "$HOME/uvws" > /dev/null || return 1
echo "📦 Adding $* to uvws workspace..."
uv add "$@" || { popd > /dev/null; return 1; }
git add pyproject.toml
git commit -m "Add $* to workspace"
git push
popd > /dev/null
echo "✅ Added $* to workspace and pushed to GitHub"
}
# Update all packages in uvws workspace
ws-update () {
if [ ! -d "$HOME/uvws" ]; then
echo "❌ uvws not found at ~/uvws"
return 1
fi
pushd "$HOME/uvws" > /dev/null || return 1
echo "📦 Updating uvws workspace packages..."
uv sync --upgrade || { popd > /dev/null; return 1; }
git add pyproject.toml
git commit -m "Update workspace packages"
git push
popd > /dev/null
echo "✅ Updated workspace packages and pushed to GitHub"
}