about summary refs log tree commit diff stats
path: root/bash/bashrc
blob: 63e56d4c57e70a76253e59af127dcacc54cb9733 (plain)
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
# bashrc -*- sh -*-

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

BASH_SOURCE_FIRST=(
    aliases
    functions
)

BASH_SOURCE_LAST=(
    blesh
    vterm-emacs
)

for f in "${BASH_SOURCE_FIRST[@]}"; do
    file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash"
    if [[ -r "$file" ]]; then
        # echo >&2 "Sourcing '$file'"
        source "$file"
    else
        :
        # echo >&2 "No '$file' found"
    fi
done

for file in "$XDG_CONFIG_HOME"/bash/*.bash; do
    file_base="${file##*/}"
    if memq "${file_base%.bash}" "${BASH_SOURCE_FIRST[@]}"; then
        # echo >&2 "'$file' in BASH_SOURCE_FIRST, skipping"
        continue
    elif memq "${file_base%.bash}" "${BASH_SOURCE_LAST[@]}"; then
        # echo >&2 "'$file' in BASH_SOURCE_LAST, skipping"
        continue
    elif [[ -r "$file" ]]; then
        # echo >&2 "Sourcing '$file'"
        source "$file"
    else
        :
        # echo >&2 "No '$file' found"
    fi
    unset file_base
done

for f in "${BASH_SOURCE_LAST[@]}"; do
    file="${XDG_CONFIG_HOME:-$HOME/.config}/bash/$f.bash"
    if [[ -r "$file" ]]; then
        source "$file"
    else
        :
        #echo >&2 "No '$file' found"
    fi
done

#ddate '+%{%A, %d %B%}, %Y%N (%H)'
true