Jan 7 2011

Fresh Ruby & Rails Install on Snow Leopard

Download and Install XCode

XCode takes a while to download so we might as well start with this. You can continue on to the next steps while it downloads… until you run into a step that requires XCode

Download and Install MySQL

I’ve built mysql several times and haven’t find an advantage over installing it from the official DMG source. Installing it from the DMG is much easier and has a higher degree of success.

Just Google for “MySQL mac download”. It should take you to the MySQL download page. Download the 64-bit DMG and do the standard thing. Open it up and run the mysql install. Also add the System Preferences to make starting and stopping the MySQL service easier.

Update your Gems Environment

gem -v
gem environment
sudo gem update --system
sudo gem update
gem list --local

You might want to install hanna also. It’s an alternate rdoc template. I have it my system configured to automatically use hanna when generating rdoc.

sudo gem install hanna

Install Homebrew for your Unix Package Needs.

Homebrew is a nice simple package manager for OS X. Some alternatives are ports and fink. I’ve used them both before and prefer ports over fink.

ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
brew

Once you install homebrew, you can easily install other packages. Ack “is a tool like grep, designed for programmers with large trees of heterogeneous source code.” Bash Completion helps make the bash command line easier to use. It’ll allow you to tab fill your ssh locations for example.

brew install git
brew install ack
brew install bash-completion

Install rvm

Here’s where we start adding some real meat to your system. rvm is not strictly necessary but highly recommanded.


# Install rvm
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
# set up rvm in .profile... or use rubyconsumer's dotfiles setup. (see below)
# To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):
rvm install 1.8.7 # installs patch 302: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
rvm --default 1.8.7

Set up Dotfiles

I have my dotfiles saved on github. I suggest either 1) look through and picking up what you need, 2) fork it, use it as is and start making your own additions. I've tried to keep it commented.

I place my configs into dropbox and symlink to them.


cd ~/Dropbox/wtsang

Clone or fork and clone dotfiles


git clone git@github.com:rubyconsumer/dotfiles.git

Set up dotfiles.


cd dotfiles
setup

My dotfiles project has a setup script which will non-destructively symlink to dotfiles. You'll need to modify it to work for you, until I make the appropriate changes since it's hardcoded to my Dropbox location.

Install Editor

Textmate is an obvious choice. If you are going to use vi, check out mac vim and carlhuda's Janus.


for i in ~/.vim ~/.vimrc ~/.gvimrc; do [ -e $i ] && mv $i $i.old; done
git clone git://github.com/carlhuda/janus.git ~/.vim
cd ~/.vim
rake


Dec 4 2008

Vim: Turn code into HTML

Maciej on his blog talks about an interesting feature in vim.

You can save highlighted source to a HTML file.
:runtime! syntax/2html.vim

So you can go from something like this:

Ruby Code in Vim

Ruby Code in Vim

To a html file like this:

Ruby Code in HTML

Ruby Code in HTML


Jul 1 2008

Block Mode Editting

I’ve been a long time VI user. Not a vi-ninja but definitely comfortable using the vi methodology.

Having used Block Mode editting in Textmate, I really needed to find a way to do the same in vi.

Volia!

Ctrl-V with ‘c’, ‘I’, and ‘A’ are the magic commands in vi

Vim Block Visual Mode


Jul 1 2008

Setting Up Unix Profiles In A Diverse Environment

I’ve recently made changes to my bash profile after getting sick and tired of managing multiple environments in one profile.

› Continue reading