-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.bashrc
More file actions
111 lines (94 loc) · 3.82 KB
/
Copy pathdot.bashrc
File metadata and controls
111 lines (94 loc) · 3.82 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
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
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, auto-launch claude on the console shell.
# CLAUDE_PROFILE lives in the container env, so it also leaks 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.
if [[ $- == *i* && -n "${CLAUDE_PROFILE:-}" && "$(tty)" == "$(readlink -f /dev/console)" ]]; then
profile="$CLAUDE_PROFILE"
unset CLAUDE_PROFILE
c "$profile"
fi