Permalink
Browse files

Updated install task, use shared function to create example scmbrc files

  • Loading branch information...
1 parent c77060a commit 63491cd97f673e9b867e39dd9e86f7d27989bafa @ndbroadbent ndbroadbent committed Oct 19, 2011
Showing with 12 additions and 12 deletions.
  1. +8 −8 install.sh
  2. +4 −4 lib/scm_breeze.sh
View
@@ -9,13 +9,13 @@ for rc in bashrc zshrc; do
fi
done
+# Load SCM Breeze update scripts
+. "$HOME/.scm_breeze/lib/scm_breeze.sh"
+# Create '~/.*.scmbrc' files from example files
+_create_or_patch_scmbrc
-# Set up ~/*.scmbrc files
-# ---------------------------------------------------------------------------------------------
-for scm in git; do
- if ! [[ -s "$HOME/.$scm.scmbrc" ]]; then
- cp "$HOME/.scm_breeze/$scm.scmbrc.example" "$HOME/.$scm.scmbrc"
- echo "== '~/.$scm.scmbrc' has been created. Please edit this file to change '$scm' settings."
- fi
-done
+# Load SCM Breeze in current shell
+. "$HOME/.scm_breeze/scm_breeze.sh"
+
+echo "== SCM Breeze loaded into current shell with default settings."
View
@@ -18,24 +18,24 @@ update_scm_breeze() {
git pull origin master
# Reload latest version of '_create_or_patch_scmbrc' function
source "$scmbDir/lib/scm_breeze.sh"
- _create_or_patch_scmbrc
+ _create_or_patch_scmbrc $oldHEAD
# Reload SCM Breeze
source "$scmbDir/scm_breeze.sh"
cd "$currDir"
}
+# Create '~/.*.scmbrc' files, or attempt to patch them if passed a previous revision
_create_or_patch_scmbrc() {
- # Create or attempt to patch '~/.*.scmbrc' files.
patchfile=$(mktemp)
for scm in git; do
# Create file from example if it doesn't already exist
if ! [ -e "$HOME/.$scm.scmbrc" ]; then
cp "$HOME/.scm_breeze/$scm.scmbrc.example" "$HOME/.$scm.scmbrc"
echo "== '~/.$scm.scmbrc' has been created. Please edit this file to change SCM Breeze settings for '$scm'."
# If file exists, attempt to update it with any new settings
- else
+ elif [ -n "$1" ]
# Create diff of example file, substituting example file for user's config.
- git diff $oldHEAD "$scm.scmbrc.example" | sed "s/$scm.scmbrc.example/.$scm.scmbrc/g" > $patchfile
+ git diff $1 "$scm.scmbrc.example" | sed "s/$scm.scmbrc.example/.$scm.scmbrc/g" > $patchfile
if [ -s $patchfile ]; then # If patchfile is not empty
cd $HOME
# If the patch cannot be applied cleanly, show the updates and tell user to update file manually.

0 comments on commit 63491cd

Please sign in to comment.