Skip to content

Loading…

shell style fix #5

Merged
2 commits merged into from

3 participants

@timurb

Fixes for shell coding style and for potential errors with space in $HOME etc.

This should work but it is completely untested. Please check on real mac if it works ok.

@ghost ghost merged commit 0b7602e into master
@ghost ghost deleted the fix_shell_coding_style branch
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 7, 2013
  1. @timurb

    shell style fix

    timurb committed
  2. @nicck
Showing with 24 additions and 20 deletions.
  1. +24 −20 bootstrap-osx.sh
View
44 bootstrap-osx.sh
@@ -1,6 +1,9 @@
#!/bin/sh
-if [ -d /Applications/Sublime\ Text\ 2.app/ ]
+APP_DIR="/Applications/Sublime Text 2.app"
+SUBLIME_DIR="$HOME/Library/Application Support/Sublime Text 2"
+
+if [ -d "$APP_DIR" ]
then
echo 'Sublime Text 2 application found.'
else
@@ -10,48 +13,48 @@ else
fi
# Add `subl` terminal command
-if [ `which subl` ]
+command -v subl > /dev/null
+if [ $? -eq 0 ]
then
- echo '`subl` terminal command already installed'
+ echo "Terminal command 'subl' already installed"
else
- if [ -d $HOME/.bin ]
+ if [ -d "$HOME/.bin" ]
+ then
+ echo "Adding terminal command 'subl' into ~/.bin"
+ ln -s "$APP_DIR/Contents/SharedSupport/bin/subl" "$HOME/.bin/subl"
+ elif [ -d "$HOME/bin" ]
then
- ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl $HOME/.bin/subl
+ echo "Adding terminal command 'subl' into ~/bin"
+ ln -s "$APP_DIR/Contents/SharedSupport/bin/subl" "$HOME/bin/subl"
else
- ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
+ echo "Adding terminal command 'subl' into /usr/local/bin"
+ ln -s "$APP_DIR/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
fi
fi
# Install package control
# http://wbond.net/sublime_packages/package_control/installation
-if [ -d $HOME/Library/Application\ Support/Sublime\ Text\ 2/ ]
+if [ -d "$SUBLIME_DIR" ]
then
echo 'Config directory found.'
else
echo 'Creating config directory'
- subl -b && sleep '0.5' && osascript -e 'tell application "Sublime Text 2" to quit'
+ subl --background && sleep '0.5' && osascript -e 'tell application "Sublime Text 2" to quit'
fi
-cd $HOME/Library/Application\ Support/Sublime\ Text\ 2/
-
-if [ -f Installed\ Packages/Package\ Control.sublime-package ]
+if [ -f "$SUBLIME_DIR/Installed Packages/Package Control.sublime-package" ]
then
echo 'Package Control already installed.'
else
echo 'Downloading Package Control'
- curl -s 'http://sublime.wbond.net/Package%20Control.sublime-package' > Installed\ Packages/Package\ Control.sublime-package
+ curl --silent --show-error 'http://sublime.wbond.net/Package%20Control.sublime-package' --output "$SUBLIME_DIR/Installed Packages/Package Control.sublime-package"
fi
-cd -
-
echo 'Add default packages and configs...'
+cp -f "settings/*" "$SUBLIME_DIR/Packages/User/"
-cp -f settings/Preferences.sublime-settings $HOME/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
-cp -f settings/Package\ Control.sublime-settings $HOME/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
-cp -f settings/Default\ \(OSX\).sublime-keymap $HOME/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
-
-echo | subl -w <<TXT
+echo | subl --wait <<TXT
# Almost done
Now Sublime Text 2 installing packages and "Soda Theme"
@@ -66,7 +69,8 @@ When it's done (you should see 'Package Control: No updated packages' line)
please close Sublime Text 2 (cmd-q). ST2 will restart automatically.
--
-nicck
+https://github.com/fs/sublime-bootstrap
TXT
subl ./
+echo 'Done.'
Something went wrong with that request. Please try again.