-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_profile
More file actions
143 lines (119 loc) · 4.45 KB
/
bash_profile
File metadata and controls
143 lines (119 loc) · 4.45 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
#!/bin/bash
# shellcheck source=/dev/null
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# XDG Base Directory Specification
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Bash Configuration Directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BASH_CONFIG_DIR="${XDG_CONFIG_HOME}/bash"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Bash History (XDG State Directory)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create state directory if it doesn't exist
mkdir -p "${XDG_STATE_HOME}/bash"
# Use XDG-compliant location for bash history
export HISTFILE="${XDG_STATE_HOME}/bash/history"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Source Bash Configuration Files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
source_bash_files() {
local config_dir="$1"
shift
local files=("$@")
for file in "${files[@]}"; do
local file_path="${config_dir}/${file}"
[[ -r "$file_path" ]] && . "$file_path"
done
}
# Source core configuration files
source_bash_files "${BASH_CONFIG_DIR}/core" \
"exports.bash" \
"options.bash" \
"colors.bash" \
"autocomplete.bash" \
"keybindings.bash"
# Source aliases
source_bash_files "${BASH_CONFIG_DIR}/aliases" \
"navigation.bash" \
"system.bash" \
"networking.bash" \
"git.bash" \
"package-managers.bash" \
"claude.bash" \
"codex.bash" \
"pi.bash"
# Source functions
source_bash_files "${BASH_CONFIG_DIR}/functions" \
"general.bash" \
"file-operations.bash" \
"utilities.bash" \
"piknik.bash" \
"git.bash" \
"github.bash" \
"asciinema.bash" \
"overmind.bash"
# Source integrations
source_bash_files "${BASH_CONFIG_DIR}/integrations" \
"bash-sensible.bash" \
"fzf.bash" \
"z-lua.bash" \
"thefuck.bash" \
"emoji-log.bash" \
"theme.bash"
# Cleanup
unset -f source_bash_files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Homebrew Configuration
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Check to see if the Mac needs Rosetta installed by testing the processor
processor=$(/usr/sbin/sysctl -n machdep.cpu.brand_string 2>/dev/null | grep -o "Apple")
if [[ -n $processor ]]; then
# Apple Silicon - Set Homebrew paths manually to avoid shell detection issues
if [[ -x "/opt/homebrew/bin/brew" ]]; then
export HOMEBREW_PREFIX="/opt/homebrew"
export HOMEBREW_CELLAR="/opt/homebrew/Cellar"
export HOMEBREW_REPOSITORY="/opt/homebrew"
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:"
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}"
fi
else
# Intel - Set Homebrew paths manually to avoid shell detection issues
if [[ -x "/usr/local/bin/brew" ]]; then
export HOMEBREW_PREFIX="/usr/local"
export HOMEBREW_CELLAR="/usr/local/Cellar"
export HOMEBREW_REPOSITORY="/usr/local/Homebrew"
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
export MANPATH="/usr/local/share/man${MANPATH+:$MANPATH}:"
export INFOPATH="/usr/local/share/info:${INFOPATH:-}"
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Starship Prompt (must be loaded after Homebrew)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[[ -r "${BASH_CONFIG_DIR}/integrations/starship.bash" ]] && . "${BASH_CONFIG_DIR}/integrations/starship.bash"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Optional: Start tmux on bash startup
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Uncomment to enable tmux auto-start
# see: https://unix.stackexchange.com/a/260248
#if test -z "$TMUX"; then
# session_num=$(
# tmux list-sessions 2>/dev/null |
# grep -v attached |
# grep -oE '^\d+:' |
# grep -oE '^\d+' |
# head -1
# )
# if test "$session_num"; then
# exec tmux attach -t "$session_num"
# else
# exec tmux
# fi
#fi