-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_bashrc.tmpl
More file actions
75 lines (65 loc) · 2.71 KB
/
dot_bashrc.tmpl
File metadata and controls
75 lines (65 loc) · 2.71 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
{{- if lookPath "rpm-ostree" -}}
# Minimal .bashrc for Fedora Atomic - source system config and add aliases
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Toolbox - enter with zsh instead of bash
alias tbx='/usr/bin/toolbox run zsh'
# Toolbox shortcuts - launch zsh if available, fallback to default shell
_tbx_enter() {
local name="$1"
if toolbox run --container "$name" sh -c 'command -v zsh' &>/dev/null 2>&1; then
toolbox run --container "$name" zsh
else
toolbox enter "$name"
fi
}
fedora() { _tbx_enter "fedora-$(rpm -E %fedora)"; }
arch() { _tbx_enter arch-rolling; }
export PATH="$HOME/.local/bin:$PATH"
# Starship prompt (cached to avoid forking Go binary on every startup)
_cache_eval() {
local name="$1"; shift
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/shell"
local cache_file="$cache_dir/${name}.bash"
mkdir -p "$cache_dir"
if [[ ! -f "$cache_file" ]] || [[ -n "$(find "$cache_file" -mtime +1 2>/dev/null)" ]]; then
eval "$@" > "$cache_file" 2>/dev/null || { rm -f "$cache_file"; eval "$@"; return; }
fi
source "$cache_file" 2>/dev/null || eval "$@"
}
if command -v starship >/dev/null 2>&1; then
_cache_eval starship 'starship init bash'
fi
{{- else -}}
#!/usr/bin/env bash
# ============================================================================
# Bash configuration
# Equivalent to zsh configuration for consistency across shells
# ============================================================================
# If not running interactively, do not do anything
[[ $- != *i* ]] && return
# ============================================================================
# Shell options
# ============================================================================
shopt -s histappend # Append to history file
shopt -s checkwinsize # Update LINES and COLUMNS after each command
shopt -s cdspell # Correct minor cd spelling errors
shopt -s dirspell # Correct directory name spelling
shopt -s autocd # Type directory name to cd into it
shopt -s globstar # Enable ** for recursive globbing
shopt -s nocaseglob # Case-insensitive globbing
# _cache_eval is defined in 00-env.bash (full version with TTL + path tracking)
# ============================================================================
# Load modular configuration files
# ============================================================================
for config_file in "${HOME}"/.bash/*.bash; do
[[ -f "${config_file}" ]] && source "${config_file}"
done
# Toolbox alias (for Linux)
{{- if eq .chezmoi.os "linux" }}
alias tbx='/usr/bin/toolbox run zsh'
{{- end }}
# Starship prompt is initialized in 99-integrations.bash (before atuin)
{{- end }}