Commits

j  committed 98dd2af

Improve bootstrap process. Add hg, git, and tar to bashrc_help.

  • Participants
  • Parent commits f0b94a3

Comments (0)

Files changed (3)

 untargzip() {
   tar -xzf "$1" --exclude="._*"
 }
+alias bz=$BZIP_BIN
 alias untar=untargzip
 alias buntar=untarbzip
 alias cp_folder="cp -Rpv" #copies folder and all sub files and folders, preserving security and dates

File etc/bashrc_help

   make
   make install'"
 
+alias help_hg="echo -e '\n${COLOR_LIGHT_PURPLE} Mercurial help:
+  ${COLOR_NC}Show summary of working copy status:
+  ${COLOR_CYAN}hg ? 
+  ${COLOR_NC}Show short summary of last few commits:
+  ${COLOR_CYAN}hg .
+  ${COLOR_NC}Show change history for a file:
+  ${COLOR_CYAN}hg log myfile
+  ${COLOR_NC}Show a diff for the file between specific revisions:
+  ${COLOR_CYAN}hg diff myfile -r 0:27
+  ${COLOR_NC}'"
+
+alias help_git="echo -e '\n${COLOR_LIGHT_PURPLE} Git help:
+  ${COLOR_NC}Show diff using external diff tool:
+  ${COLOR_CYAN}git difftool
+  ${COLOR_NC}To resolve conflicting changes after merging files from a branch or remote repository:
+  ${COLOR_CYAN}git mergetool
+  ${COLOR_NC}'"
+
 alias help_mysql="echo -e '${COLOR_LIGHT_PURPLE}MySQL: 
   ${COLOR_NC}mysql -h host_here -u user_here -p 
   ${COLOR_NC}mysqladmin -u USERNAME -p create database_name ${COLOR_GRAY} Create database
   ${COLOR_NC}mysqldump -u root -p database_name table_name >> your_output_file.sql ${COLOR_GRAY} Backup table 
   ${COLOR_NC}mysqldump -u root -p -h host_here -P 3306 --skip-opt database_name table_name ${COLOR_GRAY} Backup table, no locks, specify host 
   ${COLOR_NC}mysql -u USERNAME -p database_name < your_output_file.sql ${COLOR_GRAY} Restore from backup'"
+
+alias help_tar="echo -e '\n${COLOR_LIGHT_PURPLE} Tarball compression/decompression help:
+  ${COLOR_NC}Compress a directory into a bzipped tarball:
+  ${COLOR_CYAN}tarb <directory>
+  ${COLOR_NC}Decompress a bzipped tarball:
+  ${COLOR_CYAN}buntar yourfile.tbz
+  ${COLOR_NC}Decompress a gzipped tarball:
+  ${COLOR_CYAN}untar yourfile.tgz
+  ${COLOR_NC}'"

File etc/bootstrap.sh

     DL_TOOL="wget"
 fi
 
-# In order to install Python packages locally, site-packages must exist
-[ -d $HOME/.local/lib/python$PY_VERSION/site-packages ] || mkdir -p $HOME/.local/lib/python$PY_VERSION/site-packages
-
 # Check to see if Distribute is installed locally. If not, offer to install it.
 if [ -f ~/.local/bin/easy_install ]; then
     export EI_BIN=~/.local/bin/easy_install
 else
     echo -e "\n" && read -p "Distribute (easy_install) could not be located in ~/.local. Do you want to install it? (y/n): " -e INSTALL_DISTRIBUTE
     if [ "$INSTALL_DISTRIBUTE" = "y" ]; then
+        # In order to install Python packages locally, site-packages must exist
+        [ -d $HOME/.local/lib/python$PY_VERSION/site-packages ] || mkdir -p $HOME/.local/lib/python$PY_VERSION/site-packages
+        # Retrieve and install Distribute
         $DL_TOOL http://python-distribute.org/distribute_setup.py
         DISTRIBUTE_VERSION=`grep -Po 'DEFAULT_VERSION = "\K.*?(?=")' distribute_setup.py`
         DISTRIBUTE_URL=`grep -Po 'DEFAULT_URL = "\K.*?(?=")' distribute_setup.py`
     elif [ -f /usr/local/bin/hg ]; then
         export HG_BIN=/usr/local/bin/hg
     else
-        echo -e "\n" && read -p "Mercurial binary could not be located. Do you want to install it locally? (y/n)" -e INSTALL_HG
+        echo -e "\n" && read -p "Mercurial binary could not be located. Do you want to install it locally? (y/n): " -e INSTALL_HG
         if [ "$INSTALL_HG" = "y" ]; then
             $EI_BIN --prefix=~/.local Mercurial
-            echo -e "\n" && read -p "Enter your full name: " -e FULLNAME
-            read -p "Enter your email address: " -e EMAIL
-            echo -e "[ui]\n" > ~/.hgrc && echo -e "username = $FULLNAME <$EMAIL>\n\n" >> ~/.hgrc
-            echo -e "[hostfingerprints]\nbitbucket.org = 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b" >> ~/.hgrc
+            # Create .hgrc file if not present
+            if [ ! -f ~/.hgrc ]; then
+                echo -e "\nNo ~/.hgrc detected."
+                echo -e "\n" && read -p "Enter your full name: " -e FULLNAME
+                read -p "Enter your email address: " -e EMAIL
+                echo -e "[ui]\n" > ~/.hgrc && echo -e "username = $FULLNAME <$EMAIL>\n\n" >> ~/.hgrc
+                echo -e "[hostfingerprints]\nbitbucket.org = 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b" >> ~/.hgrc
+            fi 
             export HG_BIN=~/.local/bin/hg
         else
             echo "Bootstrap aborted: Mercurial binary could not be located."
     fi
 fi
 
-# Install hg-git
-$EI_BIN --prefix=~/.local hg-git
+# Offer to install hg-git
+echo -e "\n" && read -p "Do you want to install hg-git locally? (y/n): " -e INSTALL_HGGIT
+if [ "$INSTALL_HGGIT" = "y" ]; then
+    [ -d $HOME/.local/lib/python$PY_VERSION/site-packages ] || mkdir -p $HOME/.local/lib/python$PY_VERSION/site-packages
+    $EI_BIN --prefix=~/.local hg-git
+fi
 
 # Check to see if virtualenv is installed locally. If not, offer to install it.
 if [ ! -f ~/.local/bin/virtualenv ]; then
 echo -e "\n" && read -p "Install helpful system packages, such as byobu, ctags, git, etc? (y/n): " -e INSTALL_SYSPKGS
 if [ "$INSTALL_SYSPKGS" = "y" ]; then
     if [ "$OS" = "darwin" ]; then
-        brew update && brew install byobu ctags bash-completion ssh-copy-id wget
+        brew update && brew install bash-completion byobu ctags pbzip2 ssh-copy-id wget
         ln -s "/usr/local/Library/Contributions/brew_bash_completion.sh" "/usr/local/etc/bash_completion.d"
         if [ ! -f ~/Music/Sounds/happykids.wav ]; then
         mkdir -p ~/Music/Sounds && wget -P ~/Music/Sounds/ http://collectiveidea.com/assets/4c58e4c1dabe9d50eb000087/happykids.wav
                 && mv Menlo-ForPowerline.ttc Menlo\ for\ Powerline.ttc && rm Menlo-ForPowerline.ttc.zip menlo-powerline.tgz
         fi
     elif [ "$OS" = "linux" ]; then
-        sudo aptitude update && sudo aptitude install git-core byobu exuberant-ctags
+        sudo aptitude update && sudo aptitude install exuberant-ctags git pbzip2
     fi
 fi
 
 # Retrieve command-line tools
 if [ ! -d $CMD_TOOLS ]; then
+    echo -e "\nRetrieving command-line tools from repository..."
     $HG_BIN clone https://bitbucket.org/j/cmd $CMD_TOOLS
+fi
+
+# Install Vundle (if Git is installed)
+type -P git &>/dev/null && export GIT_BIN=`type -P git`
+if [ ! -z $GIT_BIN ]; then
+    mkdir -p $CMD_TOOLS/etc/vim/bundle ~/.vimtmp/undo ~/.vimtmp/backup ~/.vimtmp/swap
+    if [ ! -d $CMD_TOOLS/etc/vim/bundle/vundle ]; then
+        git clone http://github.com/gmarik/vundle.git $CMD_TOOLS/etc/vim/bundle/vundle
     fi
-
-# Install Vundle
-mkdir -p $CMD_TOOLS/etc/vim/bundle ~/.vimtmp/undo ~/.vimtmp/backup ~/.vimtmp/swap
-if [ ! -d $CMD_TOOLS/etc/vim/bundle/vundle ]; then
-    git clone http://github.com/gmarik/vundle.git $CMD_TOOLS/etc/vim/bundle/vundle
+else
+    echo -e "\nCould not locate Git. Skipping Vundle installation."
 fi
 
 echo -e '\nBootstrap completed. Link the new files via "source ~/tools/etc/link" and then install vim plugins via "updatevim"\n'