Use Solarized Theme In MAC Terminal For Ruby On Rails Development

Image

I am now working on 2 machines, one is a Ubuntu 12.04 and another one is MBP.  By comparison, the stock Terminal.app of Mac is too boring and hard to read (Though I’m not saying the Ubuntu’s one is good enough).  Since I like the Soda theme I set in Sublime Text in both machines, and I prefer a dark background for the terminal, so I change it to make my dev learning happier and funnier.

So here’s how.

First go to this page to download the Solarized theme file.  In my case I choose the Dark one.

Second, open the terminal app and find in menu Preferences… >> Setting.  In the bottom left under ‘Profiles’, find the cog icon and select ‘Import…’ to import the theme file you just download.

Image

Image

After Importing the file, you will have the Solarized theme in ‘Profile’, select it and make it Default (by clicking ‘Default’ besides the cog icon).

Image

Finally, place the following command into your ~/.bash_profile to bring out the ansi color.  Otherwise you’ll just have the three colors showed on the right of the ‘Text’ options in the above window.

export PS1="\[33[36m\]\u\[33[m\]@\[33[32m\]\h:\[33[33;1m\]\w\[33[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'

Save it then you’ll have the Solarized color terminal for your dev.

Advertisements

Setup Sublime Text 2 on OSX Mavericks for Ruby on Rails

1. Install Sublime Text 2.

I choose ST2 instead of ST3 simply because I don’t like using beta app for my work.

2. Verify ST2 installation works.  The follow steps refers to the good post at stackoverflow: Sublime Text 3 .subl command

In terminal, go to a folder with a few documents and type:

/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl .

If ST2 opens the folder with documents showed in the left pane, then move on to the next step.  If not, go to the post I provided link and see what you miss.

3. Modify “.bash_profile”

In terminal, type

nano ~/.bash_profile

The file will be showed in terminal, add the following 2 lines in the end of file, then save and exit.

export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH↲
export EDITOR='subl -w'

enable the newly edited .bash_profile by typing:

source ~/.bash_profile

4. Create a symlink subl for Sublime Text:

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Please note I follow the post exactly to place the link file in /usr/local/bin

Now you should be able to use subl to open any text file.

5. Install Package Control, by following this instruction.

6. Install Packages via Package Control (⌘⇧P):

My picks here: Soda Theme, RailCasts Color Scheme, CoffeeScript, Git Gutter, and RubyTest (Ruby test cannot be installed by Package Control but manually, following their instruction on their github page).

7. Edit the Settings – User in Preference.

Mine is as follow:

{
 "caret_style": "solid",
 "color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
 "font_face": "Menlo",
 "font_options":
 [
 "no_round"
 ],
 "font_size": 12,
 "ignored_packages":
 [
 "Vintage"
 ],
 "soda_folder_icons": true,
 "theme": "Soda Light.sublime-theme",
 "wide_caret": true
}

Then restart ST2 to activate the setting.

That’s it.  I’ll keep this post updated as I move further in my development.

UPDATE: 2013/11/29

As you know that .scss/.less file for CSS showed in Sublime is pure white by default, we can open a such file and form the menu, go to View > Syntax > [Optional: Open all with current extension as…] > CSS, then all .scss/.less will looks like the other CSS file with color theme.  [Source: Sublime Text 2: How to get scss and Less files to have color?]

Install ruby 2.0.0, rails 4.0.0 with rbenv on Ubuntu 12.04 LTS

I use rbenv instead of rvm siimply because rails recommended it.  If you had set up rails/ruby/rvm on your machine before, remember to uninstall them first.

To uninstall ruby

$ sudo apt-get remove ruby

To uninstall rvm

$ rvm implode

also remember to clear rvm reference in .profile .bashrc .bash_profile (hope I don’t miss any).

Let’s get started, assuming git is installed.

Update your ubuntu

$ sudo apt-get update
$ sudo apt-get upgrade

Install common libraries: (though I’m not sure whether all are necessary)

$ sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev

Install javascript runtime

$ sudo apt-add-repository -y ppa:chris-lea/node.js
$ sudo apt-get -y update
$ sudo apt-get -y install nodejs

Install rbenv

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
$ echo 'eval "$(rbenv init -)"' >> ~/.profile
$ exec $SHELL -l$ source ~/.profile

check rbenv

$ rbenv

Install ruby-build

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Install ruby

$ rbenv install 2.0.0-p247
$ rbenv global 2.0.0-p247
$ rbenv rehash

check ruby

$ ruby -v

Install rails

$ gem install rails --version 4.0.0 --no-ri --no-rdoc
$ rbenv rehash

check rails

$ rails -v

Credit:  I want to thank Tim Abell as I borrow his steps from installing rails. I spent quite sometime on figuring out to use the rbenv rehash after gem install rails. You can check Tim’s post at: http://timwise.blogspot.hk/2013/05/installing-ruby-2-rails-4-on-ubuntu.html.