-
Notifications
You must be signed in to change notification settings - Fork 0
/
plant
executable file
·88 lines (71 loc) · 2.41 KB
/
plant
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
#!/usr/bin/env bash
# File: plant
# Author: Matt Manzi
# Date: 2020-11-14
#
# In Programmer Jargon:
# Install application configurations and update your *rc file to load shell
# scripts on session start-up.
#
# In Fig Tree Jargon:
# Plant perennials and prepare your garden for annuals.
# set FIG_HOME to current directory
export FIG_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#### Includes
source "${FIG_HOME}/tool-shed/logger.bash"
source "${FIG_HOME}/tool-shed/parse_noseed.bash"
#### Main Script
# parse the noseed file
parseNoseedFile
# plant perennials
logInfo "Planting perennials"
__perennialsDir="${FIG_HOME}/perennials"
for perennial in "${__perennialsDir}"/*; do
logTrace "Evaluating perennial: ${perennial}"
if [[ ! " ${__noSeed[@]} " =~ " ${perennial}".*" " ]]; then
logTrace "Planting perennial: ${perennial}"
# provided.sh are the template file names but this will plant any script file
logInfoNoNewline "Planting ${perennial}..."
"${perennial}"/*".sh"
logInfoNoPrefix "OK"
logTrace "Finished perennial: ${perennial}"
else
logDebug "Skipping perennial: ${perennial}"
fi
done
__tendInstall () {
echo "
#### Fig Tree ####
export FIG_HOME=\"$FIG_HOME\"
source \"\${FIG_HOME}/annuals/tend$1\"
"
}
# install the tend script for Bash
logInfo "Installing tend script for Bash"
__bashrc=".bashrc"
__tendInstallBash="$(__tendInstall "$__bashrc")"
if ! grep -q 'source "${FIG_HOME' "${HOME}/$__bashrc" &> /dev/null; then
logDebug "Bash tend script is not already sourced"
echo "$__tendInstallBash" >> "${HOME}/$__bashrc"
else
logDebug "Bash tend script is already sourced"
fi
# install the tend scripts for Zsh
logInfo "Installing tend script for Zsh"
__zshrc=".zshrc"
__tendInstallZsh="$(__tendInstall "$__zshrc")"
if ! grep -q 'source "${FIG_HOME' "${HOME}/$__zshrc" &> /dev/null; then
logDebug "Zsh tend script is not already sourced"
echo "${__tendInstallZsh}" >> "${HOME}/$__zshrc"
else
logDebug "Zsh tend script is already sourced"
fi
logInfo "Installing tend script for zprofile"
__zprofile=".zprofile"
__tendInstallZprofile="$(__tendInstall "$__zprofile")"
if ! grep -q 'source "${FIG_HOME' "${HOME}/$__zprofile" &> /dev/null; then
logDebug "zprofile tend script is not already sourced"
echo "${__tendInstallZprofile}" >> "${HOME}/$__zprofile"
else
logDebug "zprofile tend script is already sourced"
fi