Skip to content

Instantly share code, notes, and snippets.

View wayneeseguin's full-sized avatar
🥰

Wayne E Seguin wayneeseguin

🥰
View GitHub Profile
#!/usr/bin/env bash
# Author: Wayne E. Seguin (wayneeseguin@gmail.com)
#
# I like the sound of 'work_on', however you can name this
# function anything that makes it easier for you to think.
#
work_on ()
{
# We are expecting project name to be the first parameter
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
PS1="\u@\h \w \$(parse_git_branch)$ "
if [[ -f ~/.bashrc ]] ; then source ~/.bashrc ; fi
#rvm_trust_rvmrcs=1 # <= This goes in ~/.rvmrc
create_file ".rvmrc", "rvm --create 1.9.2@#{appname}"
# Note I removed --pre since Bundler is 1.0.0 now.
# Also note that by default `` and system() runs via 'sh' not bash, hence the
# bash -l -c...
run "/bin/bash -l -c 'cd path/to/new/app; gem install bundler ; bundle install'"
#!/bin/bash
project_root="${project_root:-"/srv/cms/current/"}"
home_dir="${home_dir:-"/home/capdeploy"}"
rvm_path="${rvm_path:-"$home_dir/.rvm"}"
port="${1:-8000}"
environment="${2:-production}"
pids_path="${project_root}/tmp/pids/"
command="${3:-start}"
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
You can generate the .rvmrc file below by running:
rvm --create use default@myproject
[[ -s myproject.gems ]] && rvm gemset import myproject.gems
command -v bundle && bundle install
chromesize () {
ps auxww | GREP_COLOR="1;37;41" LANG=C grep --color=auto [C]hrome | awk '{sum += $6} END{print (sum / 1024) "MB"}'
}
apillet@russell:~$ cat foo.rb
FOO = 123
apillet@russell:~$ irb
ruby-1.9.2-preview1 > $:.unshift(Dir.pwd)
ruby-1.9.2-preview1 > require 'foo'
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
if [ -n "$PS1" ] ; then
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# ~/.bashrc: executed by bash(1) for non-login shells.
if [[ ! -z "$PS1" ]] ; then
export PS1='\u@\h:\w$ '
umask 022
# Bash Completion
if [[ -f ~/.bash_completion ]] ; then . ~/.bash_completion; fi
# Prompt Settings
if [[ -f ~/.bash_styles ]] ; then . ~/.bash_styles old; fi