-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc_template
91 lines (86 loc) · 2.55 KB
/
bashrc_template
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
############################################################################
# Copyright 2010 Guillaume-Jean Herbiet
# <[email protected]> - <http://www.herbiet.net>
#
# This file is part of bash-up.
#
# bash-up is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# bash-up is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bash-up. If not, see <http://www.gnu.org/licenses/>.
############################################################################
#
# Define and export the bash-up directory.
# You only need to change this if you moved your bash-up installation dir.
#
export BU_DIRECTORY=$HOME/Development/bash-up
export BU_SYSTEM=`uname -s`
export BU_HOSTNAME=`hostname -s`
#
# Create an alias to easily reload the confiugration
#
alias reload='source $BU_DIRECTORY/bashrc_template'
#
# Execute all the scripts in the "scripts" directory
# Note: those scripts can generate/update files in the other sections
#
SECTION=$BU_DIRECTORY/scripts
if [ -d $SECTION ]; then
for DIR in "$SECTION" "$SECTION/$BU_SYSTEM" "$SECTION/$BU_SYSTEM/$BU_HOSTNAME";
do
if [ -d $DIR ]; then
find $DIR -type f -or -type l -maxdepth 1 | while read FILE
do
bash $FILE
done
fi
done
fi
#
# Source all the file in the standard directories
#
for SECTION in $BU_DIRECTORY/*;
do
SECTION_NAME=`basename $SECTION`
if [[ -d $SECTION && $SECTION_NAME != "profile" \
&& $SECTION_NAME != "external" \
&& $SECTION_NAME != "scripts" \
&& $SECTION_NAME != "templates" \
&& $SECTION_NAME != "private" ]]; then
for DIR in "$SECTION" "$SECTION/$BU_SYSTEM" "$SECTION/$BU_SYSTEM/$BU_HOSTNAME";
do
if [ -d $DIR ]; then
for FILE in $DIR/*;
do
if [ ! -d $FILE ]; then
source $FILE
fi
done
fi
done
fi
done
#
# Create symbolic links to files in the "external" directory
#
SECTION=$BU_DIRECTORY/external
if [ -d $SECTION ]; then
for DIR in "$SECTION" "$SECTION/$BU_SYSTEM" "$SECTION/$BU_SYSTEM/$BU_HOSTNAME";
do
if [ -d $DIR ]; then
find $DIR -type f -or -type l -maxdepth 1 | while read FILE
do
LOCATION=$(echo $FILE | sed -e "s,$DIR,$HOME,")
ln -fs "$FILE" "$LOCATION"
done
fi
done
fi