fd86f50e7d80c945b23b99cd5e31330fb25c65d4
[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
22 # repetitive bit stolen from variables.  should make a file out of this somehow.
23 IS_DOS=$(uname | grep -i ming)
24 if [ -z "$IS_DOS" ]; then IS_DOS=$(uname | grep -i cygwin); fi
25 # now if we're stuck in DOS, then fix the feisty meow variable name.
26 if [ ! -z "$IS_DOS" ]; then
27   FEISTY_MEOW_DIR="$(cmd /c chdir | tr A-Z a-z | sed -e 's/\\/\//g')"
28 echo feisty meow dos is: $FEISTY_MEOW_DIR
29   FEISTY_MEOW_DIR="$(dos_to_unix_path "$FEISTY_MEOW_DIR")"
30 echo new feisty meow fixed dir is: $FEISTY_MEOW_DIR
31 fi
32
33 popd &>/dev/null
34
35 export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts"
36
37 # FEISTY_MEOW_GENERATED is where the generated files feisty_meow uses are located.
38 export FEISTY_MEOW_GENERATED="$HOME/.zz_auto_gen"
39 if [ ! -d "$FEISTY_MEOW_GENERATED" ]; then
40   mkdir "$FEISTY_MEOW_GENERATED"
41 fi
42 # make toast out of generated files right away, but leave any custom scripts.
43 find "$FEISTY_MEOW_GENERATED" -maxdepth 1 -type f -exec rm -f "{}" ';' &>/dev/null
44 if [ ! -d "$FEISTY_MEOW_GENERATED/custom" ]; then
45   mkdir "$FEISTY_MEOW_GENERATED/custom"
46 fi
47
48 # just a variable we use in here to refer to the generated variables file.
49 GENERATED_FEISTY_MEOW_VARIABLES="$FEISTY_MEOW_GENERATED/fmc_variables.sh"
50 # create the alias file as totally blank.
51 echo -n >"$GENERATED_FEISTY_MEOW_VARIABLES"
52 for i in FEISTY_MEOW_DIR FEISTY_MEOW_SCRIPTS FEISTY_MEOW_GENERATED; do
53   echo "export $i=${!i}" >>"$GENERATED_FEISTY_MEOW_VARIABLES"
54 done
55
56 # load our variables so we can run our perl scripts successfully.
57 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
58
59 # create our common aliases.
60 perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
61
62 if [ ! -z "$SHELL_DEBUG" ]; then
63   echo established these variables for feisty_meow assets:
64   echo ==============
65   cat "$GENERATED_FEISTY_MEOW_VARIABLES"
66   echo ==============
67 fi
68