dropped debugging
[feisty_meow.git] / scripts / core / launch_feisty_meow.sh
1 #!/bin/bash
2
3 ##############
4
5 # Fred Hamster's Feisty Meow Concerns Ltd. Startup Profile.
6 #
7 # This file is useful within .profile or other initialization scripts.
8 #
9 # Author: Chris Koeritz
10
11 ##############
12
13 # SHELL_DEBUG: if this variable is non-empty, then it causes the feisty meow
14 # scripts to print more diagnostic information when they run.  not all
15 # scripts support this, but the core ones do.
16
17 #export SHELL_DEBUG=true
18
19 ##############
20
21 export ERROR_OCCURRED=
22   # there have been no errors to start with, at least.  we will set this
23   # to non-empty if something bad happens.
24
25 if [ -z "$FEISTY_MEOW_LOADING_DOCK" ]; then
26   # FEISTY_MEOW_LOADING_DOCK is where the generated files are located.
27   # this is our single entry point we can use without knowing any variables
28   # yet in the initialization process.
29   export FEISTY_MEOW_LOADING_DOCK="$HOME/.zz_feisty_loading"
30 #hmmm: the above is kind of a constant.  that's not so great.
31
32   # make sure our main variables are established.
33   FEISTY_MEOW_VARIABLES_LOADING_FILE="$FEISTY_MEOW_LOADING_DOCK/fmc_variables.sh"
34   if [ ! -f "$FEISTY_MEOW_VARIABLES_LOADING_FILE" ]; then
35     echo -e '\n\n'
36     echo "Feisty meow scripts need initialization via the bootstrap process, e.g.:"
37     echo "  bash $HOME/feisty_meow/scripts/core/reconfigure_feisty_meow.sh"
38     echo -e '\n\n'
39     ERROR_OCCURRED=true
40   fi
41
42   ##############
43
44   # pull in our generated variables that are the minimal set we need to find
45   # the rest of our resources.
46   source "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
47
48   # Set up the temporary directory.
49   source $FEISTY_MEOW_SCRIPTS/core/create_tempdir.sh
50
51 fi
52
53 ##############
54
55 # load the larger body of standard feisty meow variables into the environment.
56 # we actually want this to always run also; it will decide what variables need
57 # to be set again.
58 source $FEISTY_MEOW_SCRIPTS/core/variables.sh
59
60 ##############
61   
62 # include helpful functions.  we do this every time rather than making it part
63 # of variable initialization, because functions cannot be exported to
64 # sub-shells in bash (much like aliases cannot, to our infinite chagrin after
65 # having migrated from korn shell...).
66 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
67   
68 # load some helper methods for the terminal which we'll use below.
69 source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh"
70
71 ##############
72   
73 # check hash table before searching path.
74 shopt -s checkhash
75 # don't check path for sourced files.
76 shopt -u sourcepath
77 # ignore duplicate lines.
78 HISTCONTROL=ignoredups
79 # append to the history file.
80 shopt -s histappend
81 # automatically update window size if needed.
82 shopt -s checkwinsize
83
84 ##############
85
86 # make history writes immediate to avoid losing history if bash is zapped.
87 echo $PROMPT_COMMAND | grep -q history
88 if [ $? -ne 0 ]; then
89   # we only change the prompt command if we think it hasn't already been done.
90   export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
91 fi
92
93 ##############
94
95 if [ -z "$LIGHTWEIGHT_INIT" ]; then
96   # perform the bulkier parts of the initialization process.
97
98   if [ ! -z "$SHELL_DEBUG" ]; then echo "heavyweight init begins..."; fi
99
100   # set up the aliases for the shell, but only if they are not already set.
101   type CORE_ALIASES_LOADED &>/dev/null
102   if [ $? -ne 0 ]; then
103     if [ ! -z "$SHELL_DEBUG" ]; then
104       echo "the aliases were missing, now they are being added..."
105     fi
106     source "$FEISTY_MEOW_LOADING_DOCK/fmc_core_and_custom_aliases.sh"
107   fi
108
109 #echo before the new labelling, terminal titles have:
110 #show_terminal_titles
111
112   # a minor tickle of the title of the terminal, unless we already have some history.
113   label_terminal_with_info
114
115   if [ ! -z "$SHELL_DEBUG" ]; then echo "heavyweight init is done."; fi
116 fi
117
118 if [ -z "$ERROR_OCCURRED" ]; then
119   # set a sentinel variable to say we loaded the feisty meow environment.
120   export FEISTY_MEOW_SCRIPTS_LOADED=true
121 fi
122