using THISDIR instead of WORKDIR
[feisty_meow.git] / scripts / core / connect_feisty_meow.sh
1 #!/bin/bash
2
3 # Author: Chris Koeritz
4
5 # this script adds the feisty inits code to .bashrc, if we think it has not yet been added.
6
7 # auto-locate the feisty meow scripts, since they supposedly are not enabled yet.
8 export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
9 # normalize the path we want to cobble together.
10 export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
11
12 echo calculated apex as $FEISTY_MEOW_APEX
13
14 do_root="$1"; shift
15
16 if [ -f "$HOME/.bashrc" ] && grep -q "launch_feisty_meow.sh" "$HOME/.bashrc"; then
17   # the stanza for loading feisty meow already seems to be present.
18   echo "Feisty Meow already seems to be configured in '~/.bashrc'."
19 else
20   # check for the --root flag to see if they're trying to get the root version of inits.
21   if [ "$do_root" != "--root" ]; then
22     # stuff the "normal user" init file into .bashrc.  not appropriate for root.
23     # this is the easy and quick start script for most folks.
24     cat $FEISTY_MEOW_APEX/infobase/feisty_inits/dot.bashrc-normal-user |
25       sed -e \
26         "s?FEISTY_MEOW_APEX=\".*\"?FEISTY_MEOW_APEX=\"$FEISTY_MEOW_APEX\"?" \
27         >> "$HOME/.bashrc"
28     echo "Feisty Meow is now configured in '~/.bashrc' for standard users."
29   else
30     # stuff the root user init file into .bashrc.  this one doesn't
31     # automatically load the feisty meow scripts.  instead, there is a macro
32     # (uhh, an alias) that loads the feisty meow scripts.  the 'fredme' macro
33     # comes from the main author of feisty meow, named fred t. hamster.  we
34     # have since added a 'feistyme' macro too, to be slightly less
35     # idiosyncratic, as if that were possible.
36     cat $FEISTY_MEOW_APEX/infobase/feisty_inits/dot.bashrc-root |
37       sed -e \
38         "s?FEISTY_MEOW_APEX=\".*\"?FEISTY_MEOW_APEX=\"$FEISTY_MEOW_APEX\"?" \
39         >> "$HOME/.bashrc"
40     echo "Feisty Meow is now configured in '~/.bashrc' for the root user."
41   fi
42 fi
43