This repository was archived by the owner on Nov 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.bash
More file actions
101 lines (79 loc) · 1.81 KB
/
init.bash
File metadata and controls
101 lines (79 loc) · 1.81 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
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/scripts:$HOME/.local/bin:" ]]; then
PATH="$HOME/.local/scripts:$HOME/.local/bin:$PATH"
fi
export PATH
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
#
# What about /etc/bashrc.d
# What about /etc/profile.d
_scan_dir ()
{
#local prefix=~/.local/bashrc.d
local prefix=$1
local ext=${2:-.sh}
local rc=
local def_prio=99
if [ -d ${prefix} ]; then
for rc in ${prefix}/*${ext} ; do
if [ -f "$rc" ]; then
local path=$prefix
local name=${rc##*/}
local short=${name:0:3}
local prio=${short//[^0-9]/}
local prio=${prio:-$def_prio}
# echo "$prefix $name"
echo "$prio $name;$prefix"
fi
done
fi
}
_add_file ()
{
>&2 echo "yoo => $1"
local path=${1%/}
local name=${path##*/}
local dir=${path%/*}
local prio=${2:-80}
if [ -f ${path} ]; then
echo "$prio $name;$dir"
#>&2 echo "yoo => $prio;$name;$dir"
# echo . /etc/bashrc
fi
}
_load_source ()
{
local prio=${1%% *}
local path=${1##*;}
local name=${1%%;*}
local name=${name:3}
local src="$path/$name"
echo "Source: $prio - $src"
}
# Load order
files=$(
{
_add_file /etc/profile
_scan_dir /etc/profile.d .sh
_scan_dir /etc/bashrc.d .sh
_scan_dir ~/.local/bashrc.d .sh;
_scan_dir ~/.local/shell/bash_init .sh;
_scan_dir ~/.local/shell/bash_ps1 .sh
_scan_dir ~/.local/shell/bash_comp .sh
_scan_dir /home/jez/volumes/data/prj/mrjk/idmgr_beta/shellhook/bash_init .sh
} | sort -u
)
echo "Load files: "
#echo "$files" | sort
_OLD_IFS=$IFS
IFS=$'\n'
for file in $files; do
_load_source $file
done
IFS=$_OLD_IFS