-
Notifications
You must be signed in to change notification settings - Fork 3
/
.bash_profile
43 lines (36 loc) · 1.55 KB
/
.bash_profile
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
# on macos, iterm and tmux will source this for every new window or pane.
# screen will *not* source this on new screen creation (ctrl+a,c)
BASH_REPORT_MISSING_SOURCES=true
prepend_new_path_if_exists() {
if [ -d "$1" ]; then
# Pop the path off PATH (with pipes) before prepending it to PATH. ;)
# This is preferable to no-op'ing if the path already exists, to ensure that system paths
# don't take precedence in tmux or screen-like environments.
local CLEAN_PATH=$(echo "${PATH}:" | sed -e "s|$1:||" -e 's|:$||')
export PATH="$1:$CLEAN_PATH"
fi
}
# don't bother adding paths if it'll do no good.
# this is to make cross-platform support cleaner.
prepend_new_path_if_exists "/opt/homebrew/bin" # apple silicon homebrew bin
prepend_new_path_if_exists "/opt/homebrew/sbin" # apple silicon homebrew static bin
prepend_new_path_if_exists "$HOME/.local/bin"
prepend_new_path_if_exists "$HOME/bin"
source_if_exists() {
if [[ -s "$1" ]]; then
source "$1"
elif $BASH_REPORT_MISSING_SOURCES; then
echo "Skipping $1"
fi
}
# TODO: move this to darwin, perhaps including the homebrew path addition above
if command -v brew &> /dev/null; then
export HOMEBREW_ROOT="$(brew --prefix)"
source_if_exists "${HOMEBREW_ROOT}/opt/asdf/libexec/asdf.sh"
source_if_exists "${HOMEBREW_ROOT}/etc/profile.d/autojump.sh"
source_if_exists "${HOMEBREW_ROOT}/etc/profile.d/bash_completion.sh"
fi
source_if_exists "$HOME/.fzf.bash" # fzf --bash > ~/.fzf.bash
source_if_exists "$HOME/.bashrc"
# always prefer the current directory's bin
export PATH="./bin:$PATH"