expanded the nit_env.sh script to register nit within .bash_profile, .bashrc
authoritsWill <guilhermerpmansur@gmail.com>
Fri, 25 Dec 2015 18:30:57 +0000 (19:30 +0100)
committeritsWill <guilhermerpmansur@gmail.com>
Sun, 27 Dec 2015 04:59:18 +0000 (05:59 +0100)
Signed-off-by: itsWill <guilhermerpmansur@gmail.com>

misc/nit_env.sh

index d0c1c0a..4b5a122 100644 (file)
@@ -119,7 +119,19 @@ __nit_env_main() {
        if [ -n "$install" ]; then
                local ne="$fulldir/misc/nit_env.sh"
                local str="test -r \"$ne\" && NIT_DIR=\"$fulldir\" . \"$ne\""
-               grep -q "$str" "$HOME/.profile" || echo "$str" >> "$HOME/.profile"
+               if [ -f "$HOME/.profile" ]; then
+                       echo "$str" >> "$HOME/.profile"
+                       echo "successfuly registered nit in .profile"
+               elif [ -f "$HOME/.bashrc" ]; then
+                       echo "$str" >> "$HOME/.bashrc"
+                       echo "successfuly registered nit in .bashrc"
+               elif [ -f "$HOME/.bash_profile" ]; then
+                       echo "$str" >> "$HOME/.bash_profile"
+                       echo "succesfuly registerd nit .bash_profile"
+               else
+                       echo "$str" >> "$HOME/.profile"
+                       echo "couldn't find .bashrc, .bash_profile, .profile. Created .profile and registered nit in it"
+               fi
        fi
 }