From 404d8fb60dddfcadd1b2b9373b8d63f968030fcf Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Tue, 23 Oct 2012 12:47:00 +0400 Subject: [PATCH] Bootstap script. --- includes/installer.sh | 6 ++---- setup/apps.sh | 3 +++ setup/bash.sh | 4 +++- setup/bootstrap.sh | 13 +++++++++++++ setup/brew.sh | 11 +++++------ setup/consolas.sh | 4 ++++ setup/imgo.sh | 3 +++ setup/npm.sh | 10 ++++++++++ setup/osx.sh | 4 ++-- setup/sublime-packages.sh | 15 +++++++++------ setup/sublime-settings.sh | 15 ++++++++++----- sublime/User/Preferences.sublime-settings | 1 + 12 files changed, 65 insertions(+), 24 deletions(-) create mode 100755 setup/bootstrap.sh create mode 100644 setup/npm.sh diff --git a/includes/installer.sh b/includes/installer.sh index 4f3cb55..677d80c 100644 --- a/includes/installer.sh +++ b/includes/installer.sh @@ -11,7 +11,7 @@ INSTALLER_DIR=`mktemp -d` # # @param $1 URL # @param $2 File name -function download_installer { +function download_installer {` echo "Downloading $1/$2..." cd "$INSTALLER_DIR" curl -LO "$1/$2" @@ -24,9 +24,7 @@ function download_installer { # @param Application name function install_app { echo "Installing $2.app..." - cp -a "$1/$2.app" "$HOME/Applications/" - #find "$1" -type d -name "*.app" -exec sh -c 'cp -a "$0" $HOME/Applications/' {} ';' - #find "$1" -type d -name "*.app" -exec sh -c 'cp -a "$0" $HOME/Applications/' {} ';' + cp -a "$1/$2.app" "/Applications/" } # Installs an application via a DMG file diff --git a/setup/apps.sh b/setup/apps.sh index e558f16..5ede40b 100755 --- a/setup/apps.sh +++ b/setup/apps.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Installs Chrome and makes it default browser + + source "$HOME/dotfiles/includes/installer.sh" diff --git a/setup/bash.sh b/setup/bash.sh index 92e27f6..34c2583 100755 --- a/setup/bash.sh +++ b/setup/bash.sh @@ -1,6 +1,8 @@ #!/bin/bash + # Installs Bash 4 and registers it as a default shell + brew install bash grep '/usr/local/bin/bash' /etc/shells >/dev/null 2>&1 && sudo bash -c "echo /usr/local/bin/bash >> /etc/shells" -chsh -s /usr/local/bin/bash $USER \ No newline at end of file +chsh -s /usr/local/bin/bash $USER diff --git a/setup/bootstrap.sh b/setup/bootstrap.sh new file mode 100755 index 0000000..24a508a --- /dev/null +++ b/setup/bootstrap.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# New Mac bootstrap + +. brew.sh +. npm.sh +. bash.sh +. consolas.sh +. imgo.sh +. osx.sh +. sublime-settings.sh +. sublime-packages.sh +. apps.sh diff --git a/setup/brew.sh b/setup/brew.sh index 76508bb..3b6d6ee 100755 --- a/setup/brew.sh +++ b/setup/brew.sh @@ -1,5 +1,7 @@ #!/bin/bash -# Based on https://github.com/mathiasbynens/dotfiles/blob/master/.brew + +# Installs Homebrew with some formulaes + # Setup Homebrew command -v brew >/dev/null 2>&1 || ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)" @@ -15,9 +17,6 @@ brew install coreutils # Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed brew install findutils -# Install wget with IRI support -#brew install wget --enable-iri - # Install more recent versions of some OS X tools brew tap homebrew/dupes brew install homebrew/dupes/grep @@ -28,7 +27,7 @@ brew install homebrew/dupes/grep brew install git brew install git-extras brew install unrar -#brew install node +brew install node # Remove outdated versions from the cellar -brew cleanup \ No newline at end of file +brew cleanup diff --git a/setup/consolas.sh b/setup/consolas.sh index 7e09de4..de70aa7 100755 --- a/setup/consolas.sh +++ b/setup/consolas.sh @@ -1,7 +1,11 @@ #!/bin/bash + +# Installs Consolas font +# # Press "Intall font" button when font dialog opens # Based on http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x + brew install cabextract TMPDIR=`mktemp -d` && { cd $TMPDIR diff --git a/setup/imgo.sh b/setup/imgo.sh index f723f4e..839807b 100755 --- a/setup/imgo.sh +++ b/setup/imgo.sh @@ -1,6 +1,9 @@ #!/bin/bash + +# Installs imgo CLI image optimizer # https://github.com/imgo/imgo + brew install exiftool imagemagick optipng libjpeg gifsicle formulas='pngout.rb defluff.rb cryopng.rb imgo.rb' diff --git a/setup/npm.sh b/setup/npm.sh new file mode 100644 index 0000000..2c47025 --- /dev/null +++ b/setup/npm.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Installs Node.js and some NPM packages + + +brew install node + +npm install -g grunt +npm install -g jshint +npm install -g bower diff --git a/setup/osx.sh b/setup/osx.sh index 06cc7a9..0adad81 100755 --- a/setup/osx.sh +++ b/setup/osx.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Sane OSX defaults # ~/.osx — http://mths.be/osx COMPUTERNAME='Mac' @@ -562,8 +563,7 @@ sudo pmset -c panicrestart 15 ############################################################################### for app in "Address Book" "Calendar" "Contacts" "Dashboard" "Dock" "Finder" \ - "Mail" "Safari" "SizeUp" "SystemUIServer" "Terminal" "Transmission" \ - "Twitter" "iCal" "iTunes"; do + "Mail" "Safari" "SystemUIServer" "Terminal" "iCal" "iTunes"; do killall "$app" > /dev/null 2>&1 done echo "Done. Note that some of these changes require a logout/restart to take effect." \ No newline at end of file diff --git a/setup/sublime-packages.sh b/setup/sublime-packages.sh index d5d6fad..8d891b6 100755 --- a/setup/sublime-packages.sh +++ b/setup/sublime-packages.sh @@ -1,32 +1,35 @@ #!/bin/bash + # Installs/updates Sublime packages # # 1. Installs Package Control (all plugins listed in `Package Control.sublime-settings` will be installed after Sublime restarts). # 2. Installs some packages from GitHub. + if [ `uname` == 'Darwin' ]; then - cd ~/Library/Application\ Support/Sublime\ Text\ 2/Installed\ Packages + DIR=~/Library/Application\ Support/Sublime\ Text\ 2/Packages else - cd ~/AppData/Roaming/Sublime\ Text\ 2/Installed\ Packages + DIR=~/AppData/Roaming/Sublime\ Text\ 2/Packages fi +[ ! -d "$DIR" ] && mkdir -p "$DIR" +cd "$DIR" + # # Package Control # -[ ! -f Package\ Control.sublime-package ] && curl -o Package\ Control.sublime-package http://sublime.wbond.net/Package%20Control.sublime-package +[ ! -d Package\ Control ] && [ ! -f Package\ Control.sublime-package ] && curl -o Package\ Control.sublime-package http://sublime.wbond.net/Package%20Control.sublime-package # # GitHub # -cd ../Packages - # Hayaku Bundle if [ -d ./hayaku ]; then echo "Updating Hayaku Bundle..." - cd hayaku + cd "$DIR/hayaku" git pull git submodule update cd .. diff --git a/setup/sublime-settings.sh b/setup/sublime-settings.sh index e580773..ae17352 100755 --- a/setup/sublime-settings.sh +++ b/setup/sublime-settings.sh @@ -1,12 +1,17 @@ #!/bin/bash + # Enables Sublime settings syncronization + if [ `uname` == 'Darwin' ]; then - cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages + DIR=~/Library/Application\ Support/Sublime\ Text\ 2 else - cd ~/AppData/Roaming/Sublime\ Text\ 2/Packages + DIR=~/AppData/Roaming/Sublime\ Text\ 2 fi -[ ! -d ../Packages.bak ] && mkdir ../Packages.bak -mv User ../Packages.bak/User -ln -s ~/dotfiles/sublime/User User \ No newline at end of file +[ ! -d "$DIR" ] && mkdir -p "$DIR/Packages" +if [ -d "$DIR/Packages/User" ]; then + mkdir "$DIR/Packages.bak" + mv "$DIR/Packages/User" "$DIR/Packages.bak/User" +fi +ln -s ~/dotfiles/sublime/User "$DIR/Packages/User" \ No newline at end of file diff --git a/sublime/User/Preferences.sublime-settings b/sublime/User/Preferences.sublime-settings index 965bc73..d6965a1 100644 --- a/sublime/User/Preferences.sublime-settings +++ b/sublime/User/Preferences.sublime-settings @@ -20,6 +20,7 @@ "save_on_focus_lost": true, "tab_completion": true, "detect_slow_plugins": false, + "scroll_past_end": true, "theme": "Soda Light.sublime-theme", // Hayaku