Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lauren Dorman
committed
Oct 28, 2016
0 parents
commit d85bd71
Showing
3 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2016, Lauren Dorman | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
komputer maschine | ||
====== | ||
|
||
komputer maschine is a shell script that gets your machine ready for design and development. | ||
|
||
This script can be ran once or as many times as you'd like. It installs everything that macOS needs to get to work. | ||
|
||
## Requirements | ||
|
||
* A komputer maschine | ||
* macOS (>10) | ||
|
||
## Install | ||
|
||
```sh | ||
curl --remote-name https://raw.githubusercontent.com/laurendorman/komputer-maschine/master/macos | ||
sh macos 2>&1 | tee ~/komputer-maschine.log | ||
``` | ||
|
||
## Debugging | ||
|
||
The log of your script, successful or not, will be saved to `~/komputer-maschine.log`. | ||
|
||
Read through it to see if you can debug the issue yourself. | ||
If not, report where the script failed into a [new GitHub Issue](https://github.com/laurendorman/komputer-maschine/issues/new). | ||
|
||
## What You Get | ||
|
||
**macOS tools:** | ||
|
||
* [XCode](https://developer.apple.com/xcode/downloads/) for | ||
* [Homebrew](http://brew.sh/) for managing operating system libraries. | ||
|
||
**Unix tools:** | ||
|
||
* [git](https://git-scm.com/) for version control. | ||
* [tmux](http://tmux.github.io/) for saving project state and switching between projects. | ||
* [zsh](http://www.zsh.org/) as your shell. | ||
|
||
**Image tools:** | ||
|
||
* [ImageMagick](http://www.imagemagick.org/) for converting, cropping, resizing and renaming images in the command line interface. | ||
|
||
**Programming languages and configuration:** | ||
|
||
* [Bundler](http://bundler.io/) for managing Ruby libraries. | ||
* [Node.js](http://nodejs.org/) and [npm](https://www.npmjs.org/) for running applications and installing JavaScript packages. | ||
* [Rbenv](https://github.com/sstephenson/rbenv) for managing versions of Ruby. | ||
* [Ruby Build](https://github.com/sstephenson/ruby-build) for installing Rubies. | ||
* [Ruby](https://www.ruby-lang.org/en/) stable for writing general-purpose code. | ||
|
||
**Applications:** | ||
|
||
* [Alfred](https://www.alfredapp.com/) for increased productivity and efficiency with macOS. | ||
* [Caffeine](http://lightheadsw.com/caffeine/) to keep your Mac awake. | ||
* [Google Chrome](https://www.google.com/chrome/) for browsing the web. | ||
* [Firefox](https://www.mozilla.org/en-US/firefox/new/) for browsing the web also, but mostly for testing. :) | ||
* [iTerm2](https://www.iterm2.com/) for a better terminal. | ||
* [Vagrant](https://www.vagrantup.com/) for creating and configuring development environments. | ||
* [VirtualBox](https://www.virtualbox.org/) for guest operating systems, when needed. | ||
* [Atom](http://atom.io) as a text editor. | ||
* [The Unarchiver](http://unarchiver.c3.cx/unarchiver) for extracting archives that are not supported by macOS out of the box. | ||
* [Sketch](https://www.sketchapp.com/) for design. | ||
* [Dash](https://kapeli.com/dash) for browsing documentation and storing code snippets. | ||
* [Slack](https://slack.com/) for more team communication and less email. | ||
* [Docker](https://www.docker.com/) for buliding, shipping and running applications. | ||
* [Spotify](https://www.spotify.com/us/) for music. | ||
|
||
## License | ||
|
||
komputer maschine is © 2016 by Lauren Dorman and is protected under the [MIT License]. | ||
|
||
[MIT License]: LICENSE | ||
|
||
## Credits and inspiration | ||
|
||
Inspired by thoughtbot's [laptop](https://github.com/thoughtbot/laptop/) and Andrew Taylor's article on [Pantheon](https://pantheon.io/blog/dev-setup-using-homebrew-os-x). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
#!/bin/sh | ||
|
||
# komputer maschine gets your macOS machine up and running quickly. | ||
# No more second guessing if you've installed the tools you need. | ||
|
||
komputer_echo() { | ||
local fmt="$1"; shift | ||
|
||
printf "\n$fmt\n" "$@" | ||
} | ||
|
||
append_to_zshrc() { | ||
local text="$1" zshrc | ||
local skip_new_line="${2:-0}" | ||
|
||
zshrc="$HOME/.zshrc" | ||
|
||
if ! grep -Fqs "$text" "$zshrc"; then | ||
if [ "$skip_new_line" -eq 1 ]; then | ||
printf "%s\n" "$text" >> "$zshrc" | ||
else | ||
printf "\n%s\n" "$text" >> "$zshrc" | ||
fi | ||
fi | ||
} | ||
|
||
# Let the user know if the script fails | ||
trap 'ret=$?; test $ret -ne 0 && printf "\nkomputer maschine failed. :(\n\n" >&2; exit $ret' EXIT | ||
|
||
set -e | ||
|
||
if [ ! -d "$HOME/.bin/" ]; then | ||
mkdir "$HOME/.bin" | ||
fi | ||
|
||
append_to_zshrc 'export PATH="$HOME/.bin:$PATH"' | ||
|
||
sudo chown -R $(whoami) /usr/local | ||
|
||
HOMEBREW_PREFIX="/usr/local" | ||
|
||
if [ -d "$HOMEBREW_PREFIX" ]; then | ||
if ! [ -r "$HOMEBREW_PREFIX" ]; then | ||
sudo chown -R "$LOGNAME:admin" /usr/local | ||
fi | ||
else | ||
sudo mkdir "$HOMEBREW_PREFIX" | ||
sudo chflags norestricted "$HOMEBREW_PREFIX" | ||
sudo chown -R "$LOGNAME:admin" "$HOMEBREW_PREFIX" | ||
fi | ||
|
||
case "$SHELL" in | ||
*/zsh) : ;; | ||
*) | ||
komputer_echo "Changing your shell to zsh..." | ||
sudo chsh -s "$(which zsh)" | ||
;; | ||
esac | ||
|
||
gem_install_or_update() { | ||
if gem list "$1" --installed > /dev/null; then | ||
gem update "$@" | ||
else | ||
gem install "$@" | ||
rbenv rehash | ||
fi | ||
} | ||
|
||
# Install XCode | ||
if type xcode-select >&- && xpath=$( xcode-select --print-path ) && | ||
test -d "${xpath}" && test -x "${xpath}" ; then | ||
komputer_echo "XCode already installed. Skipping..." | ||
else | ||
komputer_echo "Installing XCode..." | ||
xcode-select --install | ||
fi | ||
|
||
if ! command -v brew >/dev/null; then | ||
komputer_echo "Installing Homebrew..." | ||
curl -fsS \ | ||
'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby | ||
|
||
# shellcheck disable=SC2016 | ||
append_to_zshrc 'export PATH="/usr/local/bin:$PATH"' 1 | ||
|
||
export PATH="/usr/local/bin:$PATH" | ||
else | ||
komputer_echo "Updating Homebrew..." | ||
brew update | ||
fi | ||
|
||
komputer_echo "Installing services..." | ||
brew bundle --file=- <<EOF | ||
tap "homebrew/services" | ||
tap "caskroom/cask" | ||
# Unix | ||
brew "git" | ||
brew "reattach-to-user-namespace" | ||
brew "tmux" | ||
brew "vim" | ||
brew "zsh" | ||
# Image manipulation | ||
brew "imagemagick" | ||
# Programming languages | ||
brew "rbenv" | ||
brew "ruby-build" | ||
# Tools | ||
brew "npm" | ||
EOF | ||
|
||
# Check for Node | ||
if test ! $(brew list | grep node); then | ||
komputer_echo 'Installing Node...' | ||
brew install node | ||
else | ||
komputer_echo 'Node already installed. Skipping...' | ||
fi | ||
|
||
applications=( | ||
alfred | ||
caffeine | ||
google-chrome | ||
firefox | ||
iterm2 | ||
vagrant | ||
virtualbox | ||
atom | ||
the-unarchiver | ||
sketch | ||
dash | ||
slack | ||
docker | ||
spotify | ||
) | ||
|
||
komputer_echo "Installing applications..." | ||
|
||
install_application() { | ||
if test ! $(brew cask list | grep $application); then | ||
komputer_echo "Installing $application..." | ||
brew cask install --appdir="/Applications" $application | ||
else | ||
komputer_echo "$application already installed. Skipping..." | ||
fi | ||
} | ||
|
||
for application in "${applications[@]}" | ||
do install_application $application | ||
done | ||
|
||
# Clean up Homebrew files | ||
komputer_echo "Cleaning up files..." | ||
brew cleanup | ||
brew cask cleanup | ||
|
||
komputer_echo "Configuring Ruby..." | ||
|
||
find_latest_ruby() { | ||
rbenv install -l | grep -v - | tail -1 | sed -e 's/^ *//' | ||
} | ||
|
||
ruby_version="$(find_latest_ruby)" | ||
|
||
append_to_zshrc 'eval "$(rbenv init - --no-rehash)"' 1 | ||
eval "$(rbenv init -)" | ||
|
||
if ! rbenv versions | grep -Fq "$ruby_version"; then | ||
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/opt/openssl rbenv install -s "$ruby_version" | ||
fi | ||
|
||
rbenv global "$ruby_version" | ||
rbenv shell "$ruby_version" | ||
sudo gem update --system | ||
gem_install_or_update 'bundler' | ||
number_of_cores=$(sysctl -n hw.ncpu) | ||
bundle config --global jobs $((number_of_cores - 1)) | ||
|
||
komputer_echo "Congratulations! Your komputer maschine is ready to go." |