-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.bashrc
More file actions
135 lines (116 loc) · 4.72 KB
/
Copy pathdot.bashrc
File metadata and controls
135 lines (116 loc) · 4.72 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
source /workspace/.bash_profile
# share installed gems across containers via a host-mounted volume (see bin/ai).
# bundler namespaces installs as /bundle/ruby/<abi>/..., so multiple ruby
# versions coexist and native extensions are reused. start.sh (run via `s`)
# inherits this from the interactive shell.
export BUNDLE_PATH=/bundle
# due to https://github.com/ruby/rubygems/issues/9124
export BUNDLE_DEFAULT_CLI_COMMAND=install
export BUNDLE_IGNORE_FUNDING_REQUESTS=1 # no post install messages will be printed
export BUNDLE_IGNORE_MESSAGES=1 # no funding requests will be printed
export BUNDLE_SILENCE_ROOT_WARNING=1
export HISTFILE=/commandhistory/.bash_history
# append to history file after each command
export PROMPT_COMMAND="history -a"
# allows claude to start with --dangerously-skip-permissions as root
export IS_SANDBOX=1
# our own tools
export PATH=$PATH:/usr/local/bin
# Claude Code
#
# Dynamic flavor text (AI-generated filler)
export DISABLE_NON_ESSENTIAL_MODEL_CALLS=1
# No "here's what happened while you were away" recap
export CLAUDE_CODE_ENABLE_AWAY_SUMMARY=0
# the default is too low
ulimit -n 10480
# chruby
chruby_dir="${HOME}/chruby/share/chruby"
if [ -f $chruby_dir/chruby.sh ]; then
. $chruby_dir/chruby.sh
# Set RUBIES after chruby.sh (which initializes it as empty) but before
# auto.sh (which sets up a DEBUG trap that fires immediately)
RUBIES_DIR="${HOME}/.local/share/rv/rubies"
if [[ -d $RUBIES_DIR ]]; then
find $RUBIES_DIR -type d -empty -delete
RUBIES=($RUBIES_DIR/*)
fi
# auto.sh sets a DEBUG trap for auto-switching ruby versions on cd.
# Only useful in interactive shells; in scripts it breaks set -u (nounset)
# because chruby_auto uses uninitialized variables.
if [[ $- == *i* ]]; then
. $chruby_dir/auto.sh
fi
fi
alias lsa="ls -ahl"
alias b=bundle
alias l=/usr/local/bin/claude-login
alias s=/usr/local/bin/start.sh
alias x=exit
link_dotfiles () {
local dir=/settings/dotfiles
for file in ${dir}/* ${dir}/.*; do
local base
base=$(basename "$file")
[[ "$base" == "*" ]] && continue
[[ "$base" == ".*" ]] && continue
[[ "$base" == ".bashrc" ]] && continue
[[ "$base" == ".bash_profile" ]] && continue
ln -sf "$file" "$HOME"
done
}
__git_ps1() {
local branch
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
[[ -z "$branch" ]] && return
local status=""
local git_status
git_status=$(git status --porcelain 2>/dev/null)
[[ -n "$git_status" ]] && status="*"
git rev-parse --verify --quiet @{upstream} >/dev/null 2>&1 && {
local ahead behind
ahead=$(git rev-list --count @{upstream}..HEAD 2>/dev/null)
behind=$(git rev-list --count HEAD..@{upstream} 2>/dev/null)
[[ "$ahead" -gt 0 ]] && status="${status}↑${ahead}"
[[ "$behind" -gt 0 ]] && status="${status}↓${behind}"
}
echo " (${branch}${status})"
}
PS1='\[\e[1;32m\]\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[1;33m\]$(__git_ps1)\[\e[0m\]\$ '
link_dotfiles
# source user's bashrc from dotfiles if present (after container setup)
[[ -f /settings/dotfiles/.bashrc ]] && source /settings/dotfiles/.bashrc
# When bin/ai is given a profile, --resume, or cx, auto-launch the requested
# agent on the console shell. These flags live in the container env, so they
# also leak into every later `podman exec` shell (e.g. bin/pod) — guard on the
# console tty so only the systemd shell.service session auto-launches.
# /dev/console is a symlink to the console's pts (e.g. /dev/pts/0); the
# shell.service runs on that pts, while `podman exec` shells get the next pts
# and drop to a normal prompt.
# Unset first so nested shells (and claude's own subshells) don't relaunch;
# on exit you're left at a normal prompt.
auto_launch_requested=false
if [[ -n "${CLAUDE_PROFILE:-}" || -n "${CLAUDE_RESUME:-}" || -n "${CODEX_AUTO_START:-}" || -n "${CODEX_PROFILE:-}" || -n "${CODEX_RESUME:-}" ]]; then
auto_launch_requested=true
fi
if [[ $- == *i* && "$auto_launch_requested" == true ]] && \
{ [[ "${AI_AUTO_LAUNCH:-}" == 1 ]] || [[ "$(tty)" == "$(readlink -f /dev/console)" ]]; }; then
profile="${CLAUDE_PROFILE:-}"
resume="${CLAUDE_RESUME:-}"
codex_auto_start="${CODEX_AUTO_START:-}"
codex_profile="${CODEX_PROFILE:-}"
codex_resume="${CODEX_RESUME:-}"
unset AI_AUTO_LAUNCH CLAUDE_PROFILE CLAUDE_RESUME CODEX_AUTO_START CODEX_PROFILE CODEX_RESUME
if [[ -n "$codex_auto_start" || -n "$codex_resume" ]]; then
start.sh || true
cx_args=()
[[ -n "$codex_profile" ]] && cx_args+=("$codex_profile")
[[ -n "$codex_resume" ]] && cx_args+=(--resume "$codex_resume")
cx "${cx_args[@]}"
else
c_args=()
[[ -n "$profile" ]] && c_args+=("$profile")
[[ -n "$resume" ]] && c_args+=(--resume "$resume")
c "${c_args[@]}"
fi
fi