-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
215 lines (188 loc) · 9.63 KB
/
Copy path.bashrc
File metadata and controls
215 lines (188 loc) · 9.63 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
# ~/.bashrc — bash port of ~/.zshrc (managed in dotfiles)
#
# zsh-specific machinery has been translated to its closest bash equivalent:
# zinit / plugins -> dropped (zsh-only); atuin/fzf/carapace cover the gaps
# compinit -> bash-completion
# setopt HIST* -> HISTCONTROL / shopt / PROMPT_COMMAND
# ZLE + bindkey -> readline `bind`
# zstyle completion -> readline `set ...`
# path=(...) array -> PATH prepends
# See inline NOTEs where there is no direct equivalent.
# ── Environment ──────────────────────────────────────────────────────────────
# Claude Code OTel telemetry -> athens LGTM stack via otlp.lan.cnb.rocks proxy
export CLAUDE_CODE_ENABLE_TELEMETRY="1"
export OTEL_METRICS_EXPORTER="otlp"
export OTEL_LOGS_EXPORTER="otlp"
export OTEL_EXPORTER_OTLP_PROTOCOL="grpc"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp.lan.cnb.rocks:443"
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
export OTEL_METRIC_EXPORT_INTERVAL="60000"
export OTEL_LOGS_EXPORT_INTERVAL="5000"
export OTEL_RESOURCE_ATTRIBUTES="service.namespace=claude-code,service.name=cohnesor,deployment.environment=workstation,host.name=$(hostname -s)"
export BUN_INSTALL="$HOME/.bun"
export ANTHROPIC_LOG=error
export EDITOR=nvim
export PI_TELEMETRY=0
export CNB_NO_UPDATE_NOTICE="1"
# export CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL="1"
# export GITLAB_URI=https://software.cottinghambutler.com
# PATH (mirrors the zsh `path=(...)` array + individual prepends)
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export PATH="$BUN_INSTALL/bin:$PATH"
# Nervous MCP token (refreshed by cnb). Guarded so a missing/unauthed cnb does
# not break shell startup.
if command -v cnb >/dev/null 2>&1; then
NERVOUS_MCP_TOKEN="$(cnb auth token 2>/dev/null)" && export NERVOUS_MCP_TOKEN
fi
# ── Functions ────────────────────────────────────────────────────────────────
# JWT-based auth via cnb (Dex). Wraps the `claude` CLI so the access token is
# captured at each invocation; cnb auto-refreshes via the offline_access RT.
# Token lifetime is ~24h — restart `claude` if a single session outlives it.
claude() {
local tok
tok=$(cnb auth token 2>/dev/null) || { echo "run: cnb auth login" >&2; return 1; }
HEADROOM_TELEMETRY=off OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer $tok" command claude "$@"
}
# cf is find-all — cd into the directory the `cf` program prints
cf() {
local dir
dir=$(command cf "$@")
if [ -n "$dir" ]; then
cd "$dir"
fi
}
# mrr: `mr` + immediately merge it (-d removes the source branch). GitLab
# computes mergeability asynchronously after create, so the merge API 405s
# for a few seconds — retry until it lands. glab's default --auto-merge
# waits for a running pipeline instead of failing.
mrr() {
cnb mr create -A -y "$@" || return
local i
for i in 1 2 3 4 5; do
glab mr merge -d -y && return
if [ "$i" -lt 5 ]; then
echo "mrr: merge not ready yet, retrying in $i s ($i/5)" >&2
sleep $i
fi
done
return 1
}
# ── Aliases ──────────────────────────────────────────────────────────────────
# cfi is find-all dirs ignoring .git
alias cfi='cd $(find . -type d -path "./.git" -prune -o -type d -not -path "*/\.*" -print | fzf --reverse --preview "ls --color {}")'
alias codex='codex --yolo'
alias cclds="claude --dangerously-load-development-channels plugin:firepit@pantheon-skills --dangerously-skip-permissions --model=sonnet $@"
alias ccldo="claude --effort=xhigh --dangerously-load-development-channels plugin:firepit@pantheon-skills --dangerously-skip-permissions --model='opus[1m]' $@"
alias ccldk="claude --dangerously-load-development-channels plugin:firepit@pantheon-skills --dangerously-skip-permissions --model=haiku $@"
alias cldo="claude --effort=low --dangerously-skip-permissions --model='opus[1m]' $@"
alias clds="claude --dangerously-skip-permissions --model=sonnet $@"
alias cldk="claude --dangerously-skip-permissions --model=haiku $@"
alias nvimf='~/dotfiles/modules/programs/nvimf/nvimf'
alias nviml='~/dotfiles/modules/programs/nviml/nviml'
alias mr='cnb mr create -A -y'
alias g='git'
alias git-reset='git checkout main && git pull'
alias gr='git-reset'
alias gs='git status'
alias gd='git diff'
alias gsh='git stash'
alias gsp='git stash pop'
# nvimfi is find-all files ignoring .git
alias nvimfi='nvim "$(find . -type f -path "./.git" -prune -o -type f -not -path "*/\.*" -print | fzf --preview "bat --color=always {}")"'
# rfi copies the realpath of an fzf-picked file to the clipboard
alias rfi='realpath "$(find . -type f -path "./.git" -prune -o -type f -not -path "*/\.*" -print | fzf --preview "bat --color=always {}")" | pbcopy'
alias nxi='nix'
alias wtr='git worktree remove'
alias wtl='git worktree list'
alias wta='git worktree add'
alias wt='git worktree'
alias wtd='git worktree remove'
alias k='kubectl'
alias nix-env='echo "panic: nix-env is disabled (#61)" >&2 && false'
# alias pnpm='echo "panic: pnpm is unsupported, we use bun" >&2 && false'
alias vim='nvim'
alias v='nvim'
alias vf='nvimf'
alias vfi='nvimfi'
alias kl='klaude'
if command -v cnb >/dev/null 2>&1; then
alias os='cnb rocks'
alias osv='cnb rocks validate --all --strict'
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
else
alias os='spectr'
alias osv='spectr validate --all --strict'
fi
# ── Interactive shell only below ─────────────────────────────────────────────
case $- in *i*) ;; *) return ;; esac
# NOTE: the `bash` on PATH may be a minimal build without readline / programmable
# completion (e.g. Nix's `bash` package vs `bashInteractive`; check with
# `set -o vi` — "invalid option name" means no readline). Each block below is
# gated on the capability it needs, so startup stays clean on any bash.
# History — bash equivalents of the zsh HIST* / setopt block (no readline needed).
HISTFILE=~/.bash_history
HISTSIZE=10000 # in-memory (zsh HISTSIZE)
HISTFILESIZE=10000 # on-disk (zsh SAVEHIST)
# ignorespace+ignoredups (hist_ignore_space/_dups) + erasedups (hist_ignore_all_dups/hist_save_no_dups)
HISTCONTROL=ignoreboth:erasedups
shopt -s histappend # appendhistory
# NOTE: zsh WORDCHARS, hist_reduce_blanks and hist_find_no_dups have no direct
# bash equivalent — atuin handles fuzzy/dedup history search.
# Prompt / directory tools — no readline required, safe on any bash.
# (zoxide is intentionally initialized LAST — see the bottom of this file.)
command -v starship >/dev/null 2>&1 && eval "$(starship init bash)"
command -v direnv >/dev/null 2>&1 && eval "$(direnv hook bash)"
# Programmable completion (zsh compinit). Needs the `complete` builtin, which is
# absent in minimal bash builds — gate on `progcomp` so sourcing never errors.
if shopt -q progcomp 2>/dev/null; then
for _bc in \
"$HOME/.nix-profile/etc/profile.d/bash_completion.sh" \
"$HOME/.nix-profile/share/bash-completion/bash_completion" \
/usr/local/etc/profile.d/bash_completion.sh \
/etc/profile.d/bash_completion.sh \
/usr/share/bash-completion/bash_completion \
/etc/bash_completion; do
[ -r "$_bc" ] && { . "$_bc"; break; }
done
unset _bc
command -v kubectl >/dev/null 2>&1 && source <(kubectl completion bash)
fi
export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional
source <(carapace _carapace)
source <(carapace chmod bash)
# Readline / line editing (zsh ZLE). Absent in minimal bash builds (`bind` is not
# a builtin there) — gate fzf/atuin key widgets, vi mode and key bindings on it.
if type -t bind >/dev/null 2>&1; then
command -v fzf >/dev/null 2>&1 && eval "$(fzf --bash)"
command -v atuin >/dev/null 2>&1 && eval "$(atuin init bash)"
set -o vi # zsh jeffreytse/zsh-vi-mode. Remove for emacs editing mode.
# Key bindings (zsh `bindkey` from zvm_after_init + edit-command-line)
bind '"\C-x\C-x": edit-and-execute-command' # ^X^X: edit command line in $EDITOR
bind '"\C-p": history-search-backward'
bind '"\C-n": history-search-forward'
bind '"\e[1;5C": forward-word' # ctrl-right
bind '"\e[1;5D": backward-word' # ctrl-left
# Completion behaviour (zsh zstyle matcher-list / list-colors / menu)
bind 'set completion-ignore-case on'
bind 'set colored-stats on'
bind 'set colored-completion-prefix on'
bind 'set show-all-if-ambiguous on'
fi
# Share history across sessions (zsh `sharehistory`). Prepend so it runs ahead of
# starship's / atuin's PROMPT_COMMAND.
PROMPT_COMMAND="history -a; history -n${PROMPT_COMMAND:+; $PROMPT_COMMAND}"
# NOTE: zinit + its zsh plugins (zsh-autosuggestions, zsh-syntax-highlighting,
# fzf-tab, zsh-completions, zpm-zsh/clipboard) are zsh-only. atuin, fzf,
# carapace and the readline settings above cover the equivalent bash features.
# Added by Antigravity CLI installer
export PATH="/Users/cohnesor/.local/bin:$PATH"
# zoxide — MUST be initialized last. zoxide hooks PROMPT_COMMAND and its doctor
# warns if anything (starship, direnv, atuin/bash-preexec, the history-share line
# above) edits PROMPT_COMMAND after it. Keeping it at the very end of the file
# satisfies that requirement. Set _ZO_DOCTOR=0 to silence the check instead.
if command -v zoxide >/dev/null 2>&1 && [[ "$CLAUDECODE" != "1" ]]; then
eval "$(zoxide init --cmd cd bash)"
fi
ulimit -n 65536