more fixes from windows.
[feisty_meow.git] / scripts / core / bootstrap_shells.sh
1 #!/bin/bash
2 #
3 # bootstrap_shells:
4 #
5 # This script creates the directory for auto-generated scripts and gets
6 # the current user's account ready to use the feisty meow scripts.
7 #
8 # Note: this does not yet ensure that the profile is executed on shell
9 # startup.  that can be added manually by editing your .bashrc file.
10 # read the examples/feisty_meow_startup/bashrc_user file for more details.
11
12 ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && \pwd )"
13 CORE_SCRIPTS_DIR="$(echo "$ORIGINATING_FOLDER" | tr '\\\\' '/' )"
14 THIS_TOOL_NAME="$(basename "$0")"
15
16 # set up the feisty_meow dir.
17 pushd "$CORE_SCRIPTS_DIR/../.." &>/dev/null
18 source "$CORE_SCRIPTS_DIR/functions.sh"
19
20 export FEISTY_MEOW_DIR="$(\pwd)"
21 popd &>/dev/null
22
23 export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts"
24
25 # FEISTY_MEOW_GENERATED is where the generated files feisty_meow uses are located.
26 export FEISTY_MEOW_GENERATED="$HOME/.zz_auto_gen"
27 if [ ! -d "$FEISTY_MEOW_GENERATED" ]; then
28   mkdir "$FEISTY_MEOW_GENERATED"
29 fi
30 # make toast out of generated files right away, but leave any custom scripts.
31 find "$FEISTY_MEOW_GENERATED" -maxdepth 1 -type f -exec rm -f "{}" ';' &>/dev/null
32 if [ ! -d "$FEISTY_MEOW_GENERATED/custom" ]; then
33   mkdir "$FEISTY_MEOW_GENERATED/custom"
34 fi
35
36 # just a variable we use in here to refer to the generated variables file.
37 GENERATED_FEISTY_MEOW_VARIABLES="$FEISTY_MEOW_GENERATED/fmc_variables.sh"
38 # create the alias file as totally blank.
39 echo -n >"$GENERATED_FEISTY_MEOW_VARIABLES"
40 for i in FEISTY_MEOW_DIR FEISTY_MEOW_SCRIPTS FEISTY_MEOW_GENERATED; do
41   echo "export $i=${!i}" >>"$GENERATED_FEISTY_MEOW_VARIABLES"
42 done
43
44 # load our variables so we can run our perl scripts successfully.
45 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
46
47 # create our common aliases.
48 perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
49
50 if [ ! -z "$SHELL_DEBUG" ]; then
51   echo established these variables for feisty_meow assets:
52   echo ==============
53   cat "$GENERATED_FEISTY_MEOW_VARIABLES"
54   echo ==============
55 fi
56