Skip to content

Commit

Permalink
Merge pull request #64 from cloverinteractive/hotfix/house-clean-macp…
Browse files Browse the repository at this point in the history
…orts

Remove macports from installer and README, and add Installer
  • Loading branch information
aalvarado committed Dec 16, 2015
2 parents c65ed08 + 1499fca commit 37c7e50
Show file tree
Hide file tree
Showing 13 changed files with 441 additions and 61 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
13 changes: 12 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
GEM
remote: http://rubygems.org/
specs:
activesupport (3.0.0)
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
i18n (0.7.0)
json (1.8.3)
minitest (5.8.2)
rake (10.4.2)
term-ansicolor (1.0.7)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby
Expand Down
133 changes: 103 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,141 @@ or send a pull request.

## Install

* `git clone https://github.com/cloverinteractive/dotfiles.git ~/.dotfiles`
* `cd ~/.dotfiles`
* `bundle install`
* `rake`
We try to keep installing as simple as possible by keeping the steps to a minimum and our dotfiles as backward compatible across the couple of OS we use
the most.

Your original dotfiles will be renamed to `name.orig` so no worries.
### Online installer

We provide a simple online installer, if you're running Ubuntu, Debian or OSX, it will automatically try to resolve dependencies, install rbenv, install
homebrew or linuxbrew depending on the OS you're running; if your OS is not supported you can still resolve dependencies and generate the files manually.

`curl https://raw.githubusercontent.com/cloverinteractive/dotfiles/master/install | sh`

Check our [developers](#developers) section of this README to learn how to run the installer in a virtual machine.

### Github checkout

If you want to resolve dependencies on your own, you can install by doing a simple github checkout.

```bash
# We like to keep dotfiles somewhere in $HOME but you can clone anywhere you have permission to
git clone https://github.com/cloverinteractive/dotfiles.git ~/.dotfiles

cd ~/.dotfiles
bundle install
rake
```

Your original dotfiles will be renamed to `name.orig` so you can always restore them.

## Uninstall

* `cd ~/.dotfiles`
* `rake uninstall`
Our uninstall script is still a work in progress, to run it simply do run the uninstall task from your dotfiles folder.

```bash
rake uninstall
```

Afterwards you can optionally `rm -fr ~/.dotifiles` if you wish, your `name.orig` files will be restored by having run `rake uninstall`.

## Prerequisites

* [ruby](http://www.ruby-lang.org) of course
Only if you don't run the `install` script provided

* [ruby](http://www.ruby-lang.org)
* [bundler](http://gembundler.com/)

`gem install bundler`

## Your Bash config isn't enough for me
### Getting ruby

It is likely you have defined functions or aliases not contained in this config and you are worried to upgrade and lose them, in order to kep them and load them
you only need to create a file named `.bash_profile.before` which will be loaded before our `.bash_profile` and a file named `.bash_profile.after` which will
be loaded after.
We recommend getting ruby via [rbenv](https://github.com/sstephenson/rbenv) and [ruby-build](https://github.com/sstephenson/ruby-build). This is the way our remote installer
installs ruby, however this is not mandatory; you can install ruby in anyway you want.

## Upgrade single bits

If you already have dotfiles installed (all symlinks have been created) you can upgrade small bits like this:

* `cd ~/.dotfiles`
* `git pull`
* `rake bash # bash being the bit you wish to upgrade`
```bash
cd ~/.dotfiles
git pull
rake bash # bash being the bit you wish to upgrade
```

If you don't know what bits are available in dotfiles; simply run `rake -T` for a full list of tasks.

## Commands that will make this enjoyable

### OSX + macports
These dotfiles include configuration tweaks for:

* ncmpcpp
* bash
* rubygems
* git
* vim
* tmux
* postgresql
* ack

* p5-app-ack
* git-core
To get most of these dotfiles we recommend installing these packages

## Homebrew

Homebrew makes managing and installing packages in both Linux and OSX pretty simple. This is not required for Linux since most distributions have a pretty robust package manager;
hoewever homebrew allows you to install packages directly into `$HOME` without special permissions, and in many cases unavailable or newer packages that your OS package manager does
not include.

You can install each of this with a simple `brew install <package>`.

### OSX with [Homebrew](https://github.com/Homebrew/homebrew)

If you're on a mac we highly recommend using [Homebrew](https://github.com/Homebrew/homebrew), it's constantly getting updates and it's pretty clean and easy to manage, here's
a list of packages you should be looking to install.

* git
* coreutils
* vim
* macvim
* ruby
* rb-rubygems
* bash-completion
* tmux
* readline
* openssl

### Linux with [Linuxbrew] (https://github.com/Homebrew/linuxbrew)

If you're using linux and would like to install packages to your `$HOME` then [Linuxbrew](https://github.com/Homebrew/linuxbrew) is a simple way to get this done, like homebrew it gets
frequent updates and it's pretty clean and easy to maintain, not to mention it has formulas for many of the same packages homebrew does, should a package not be present it's only a matter
of falling back to the OS package manger.

## Developers

We try to make development as simple as possible for [ourselves](https://github.com/cloverinteractive/dotfiles/graphs/contributors), therefore we've worked in a way of easily running our
scripts in a virtual machine that we can use a sandbox our [installer](https://github.com/cloverinteractive/dotfiles/blob/master/install) can be ran from vagrant.

To start playing with our setup you'll need [vagrant](https://www.vagrantup.com/) and [virtualbox](https://www.virtualbox.org/), you can use hombrew's `brew cask install vagrant virtualbox` in
OSX if you already have homebrew installed or download the installers provided for your OS in both of the official sites.

```bash
git clone https://github.com/cloverinteractive/dotfiles.git
cd dotfiles

You can install each of this with a simple `port install <package>`.
# This will run vagrant in the background and setup a test box or boot it if you already have one
vagrant up

## Pry
# This will connect you to your new virtual machine via ssh
vagrant ssh
```

If you install the pry gem the dotfiles config will give it access to the Rails stack so when in a rails project just run `pry` instead of `rails c`.
Once in vagrant, your project folder will be synced into your VM's `/vagrant` folder, that means you do not need to exit ssh to make changes or disconnect if you do change something in your OS;
You can run the installer from `/vagrant` and even pass it the name of the branch to install like this:

## tmux bindings
```bash
# Run installer from the /vagrant folder
/vagrant/install features/my-cool-feature

For convenience we have changed the following to the `tmux` config:
# Log out and log back in or load ~/.bash_profile
source ~/.bash_profile
```

* To be consistent with `screen` (yeah I'm an old `screen` user) instead of binding the `tmux` prefix to `C-b` we prefix to `C-a`.
* We binded `|` to `split-window -v`, it makes it more obvious you meant vertical split.
* We binded `-` to `split-window -h`, it makes it more obvious you meant horizontal split.
When you're done you can shutdown vagrant by running `vagrant halt`.

## issues

Expand Down
6 changes: 1 addition & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ include Term::ANSIColor
$is_darwin = RUBY_PLATFORM.include? 'darwin'
$is_linux = RUBY_PLATFORM.include? 'linux'

$has_macports = `which port`.present?
$has_apt = `which apt-get`.present?

$prefix = ENV['PREFIX'] || ENV['HOME']
$dotfiles_path = File.dirname( __FILE__ )

Expand Down Expand Up @@ -118,8 +115,6 @@ def parse_config file
erb_env = Proc.new do
@is_darwin = $is_darwin
@is_linux = $is_linux
@has_macports = $has_macports
@has_apt_get = $has_apt
@prefix = $prefix

binding
Expand All @@ -139,4 +134,5 @@ def restore_from_backup file
FileUtils.mv "#{ dst_name }.orig", dst_name if File.exists? "#{ dst_name }.orig"
end

task :default => :install
task :install => [ "bash", "vim", "git", "ack", "gem", "tmux", 'psql', "ncmpcpp" ]
84 changes: 84 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.define "linux" do |linux|
linux.vm.box = "ubuntu/trusty64"
end

config.vm.define "osx" do |osx|
osx.vm.box = "AndrewDryga/vagrant-box-osx"

#
# There are no Virtual Box Guest Additions for OSX the only way to test share this folder at the moment is
# via NFS, for this to work you'll need a host-only connection wit DHCP from guest to host and to uncomment
# this line, if box is already running you can run vagrant reload osx
#
# osx.vm.synced_folder ".", "/vagrant", id: "core", nfs: true, mount_options: ['nolock,vers=3,udp,noatime']
end

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.

# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get install -y apache2
# SHELL
end
36 changes: 36 additions & 0 deletions bash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Bash

## Your Bash config isn't enough for me

It is likely you have defined functions or aliases not contained in this config and you are worried to upgrade and lose them, in order to kep them and load them
you only need to create a file named `.bash_profile.before` which will be loaded before our `.bash_profile` and a file named `.bash_profile.after` which will
be loaded after.

### $PATH

We always put `./bin` and `$HOME/bin` at the begining of `$PATH`.

```bash
export PATH=./bin:$HOME/bin:$PATH
```

The idea is that you can just put any script into any bin folder and the home folder and bash will know to look there or `$HOME/bin` before trying your system `bin` or
hombrew's path. If you need to change `$PATH` it is recommended that you do so at th `.bash_profile.before`, if that's not a possibility you can always move this line to
`.bash_profile.after`.

## Checkout what's listening

Our bash config includes a `listening` alias that shows what is listening and in what port here's how it looks:

![listening](listening.png)


## Command Prompt

Our bash config includes a couple of git related functions `current_git_branch` and `current_git_stash` all these do is check the what the current `git` branch is if we're in a git
project and color it green, `current_git_stash` check how many elements are in the `git` stash (if any) and put the count into brackets, and color it pink. There's another function
not git `last_return_status` related that checks the last return code and pring a green smiley or a red frowny.

This is how all three functions looked combined in `$PROMPT_COMMAND`:

![prompt](prompt.png)
Loading

0 comments on commit 37c7e50

Please sign in to comment.