5 # Fred Hamster's Feisty Meow Concerns Ltd. Startup Profile.
7 # This file is useful within .profile or other initialization scripts.
9 # Author: Chris Koeritz
13 # DEBUG_FEISTY_MEOW: 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.
17 #export DEBUG_FEISTY_MEOW=true
21 ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && /bin/pwd )"
22 CORE_SCRIPTS_DIR="$(echo "$ORIGINATING_FOLDER" | tr '\\\\' '/' )"
23 THIS_TOOL_NAME="$(basename "$0")"
24 # repair some paths that we should always be able to auto-calculate.
25 export FEISTY_MEOW_SCRIPTS="$( \cd "$CORE_SCRIPTS_DIR/.." && /bin/pwd )"
26 export FEISTY_MEOW_APEX="$( \cd "$FEISTY_MEOW_SCRIPTS/.." && /bin/pwd )"
30 # some preconditions we want to establish before loading anything...
32 # make sure that aliases can be used in non-interactive shells.
33 shopt -s expand_aliases
35 # patch the user variable if we were launched by one of our cron jobs.
36 if [ -z "$USER" -a ! -z "$CRONUSER" ]; then
37 export USER="$CRONUSER"
42 export ERROR_OCCURRED=
43 # there have been no errors to start with, at least. we will set this
44 # to non-empty if something bad happens.
46 if [ -z "$FEISTY_MEOW_LOADING_DOCK" ]; then
47 # FEISTY_MEOW_LOADING_DOCK is where the generated files are located.
48 # this is our single entry point we can use without knowing any variables
49 # yet in the initialization process.
50 export FEISTY_MEOW_LOADING_DOCK="$HOME/.zz_feisty_loading"
51 #hmmm: the above is kind of a constant. that's not so great.
53 # make sure our main variables are established.
54 FEISTY_MEOW_VARIABLES_LOADING_FILE="$FEISTY_MEOW_LOADING_DOCK/fmc_variables.sh"
55 if [ ! -f "$FEISTY_MEOW_VARIABLES_LOADING_FILE" ]; then
58 The feisty meow scripts need initialization via the bootstrap process. For\n\
59 example, if the feisty meow folder lives in '$DEFAULT_FEISTYMEOW_ORG_DIR', then this\n\
60 command bootstraps feisty meow:\n\
62 bash $example_dir/feisty_meow/scripts/core/reconfigure_feisty_meow.sh\n\
70 if [ -z "$ERROR_OCCURRED" ]; then
72 # pull in our generated variables that are the minimal set we need to find
73 # the rest of our resources.
74 source "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
76 # Set up the temporary directory.
77 source "$FEISTY_MEOW_SCRIPTS/core/create_tempdir.sh"
84 if [ -z "$ERROR_OCCURRED" ]; then
86 # load the larger body of standard feisty meow variables into the environment.
87 # we actually want this to always run also; it will decide what variables need
89 source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
93 # include helpful functions. we do this every time rather than making it part
94 # of variable initialization, because functions cannot be exported to
96 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
98 # load some helper methods for the terminal which we'll use below.
99 source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh"
103 # check hash table before searching path.
105 # don't check path for sourced files.
107 # ignore duplicate lines.
108 HISTCONTROL=ignoredups
109 # append to the history file.
111 # automatically update window size if needed.
112 shopt -s checkwinsize
116 # make history writes immediate to avoid losing history if bash is zapped.
117 echo $PROMPT_COMMAND | grep -q history
118 if [ $? -ne 0 ]; then
119 # we only change the prompt command if we think it hasn't already been done.
120 export PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
125 # perform the bulkier parts of the initialization process.
127 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo "heavyweight init begins..."; fi
129 # set up the aliases for the shell, but only if they are not already set.
130 type CORE_ALIASES_LOADED &>/dev/null
131 if [ $? -ne 0 ]; then
132 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
133 echo "the aliases were missing, now they are being added..."
135 source "$FEISTY_MEOW_LOADING_DOCK/fmc_core_and_custom_aliases.sh"
138 #echo before the new labelling, terminal titles have:
139 #show_terminal_titles
141 # a minor tickle of the title of the terminal, unless we already have some history.
142 label_terminal_with_info
144 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo "heavyweight init is done."; fi
146 if [ -z "$ERROR_OCCURRED" ]; then
147 # set a sentinel variable to say we loaded the feisty meow environment.
148 export FEISTY_MEOW_SCRIPTS_LOADED=true
151 fi # no error occurred.