The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
RubyBuntu -3- Be one with your command line!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
RubyBuntu -3- Be one with your command line! Posted: Apr 29, 2010 5:11 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: RubyBuntu -3- Be one with your command line!
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

Most Ruby programmers know: Many things can be done in much less time on the command line. To become more productive, you should take the 10 minutes to configure some basic settings.

Tweak your terminal

Why use complicated shortcuts for often used functionality? Adjust them to your needs at Edit/Keyboard Shortcuts…. Here are my recommendations:

Action Shortcut Key
New Tab Ctrl+Return
New Window Ctrl+Alt+Return
Move Tab to the Left Ctrl+Shift+Left
Move Tab to the Right Ctrl+Shift+Right
Switch to Next Tab Ctrl+Right
Switch to Previous Tab Ctrl+Left

After that, go to Edit/Profile Preferences and set some nice colors. I like orange on black with the Tango theme and a little bit transparency. Other useful settings include increasing the scrollback lines and hiding the menubar.

More convenience

Do yourself a faviour by maintaining shell aliases. Just add some lines to your ~/.bashrc or ~/.bash_aliases with this syntax:

alias rs='script/server'
alias rsp='script/server production'
alias ai='sudo apt-get install'
alias sth='some other --command' ...

Another thing, that really makes live easier when using the console, is the Tab key and its auto completion… So why don’t use it for rake? There is a handy rake auto completion available in the ubuntu-on-rails ppa repository. You can add the ppa and install the completion with these commands:

sudo add-apt-repository ppa:ubuntu-on-rails
sudo apt-get update
sudo apt-get install rake-completion

Interactive Ruby

Now you already have a friendly console environment. But there are still things to improve about the Ruby programmer’s favourite console: irb.

Sometimes you get complex return values, where it might be a little bit complicated to get the essence of the return value. But it can be simplified by two very nice gems: wirble and hirb.

wirble makes your irb sessions colorful (colors are great!). hirb, however, lets you view many instances of big objects in a nice table – perfect for Active Record models!

sudo gem install wirble hirb

You can both auto-activate them for each irb session (and activate simple indention) by adding the following lines to your ~/.irbrc file:

Listing 1
/21/irbrc.rb ruby
%w|rubygems wirble hirb|.each do|lib|
  begin
    require lib
  rescue LoadError => err
    warn "Couldn't load an irb gem: #{err}"
  end
end

# wirble (colors)
Wirble.init
Wirble.colorize

# hirb (active record)
Hirb::View.enable

# IRB Options
IRB.conf[:AUTO_INDENT] = true

Two more hints on git

If you are using the git version control system, the first thing you should do is activating the colors:

git config --global color.ui true

Another cool and useful enhancement is showing your git branch at the prompt. Simply add this script to your ~/.bashrc (based on 1, 2, 3):

# show branch and dirty status, http://henrik.nyh.se/2008/12/git-dirty-prompt, http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
function parse_git_dirty {
  [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "⚡"
}
function parse_git_branch {
  local branch=$(__git_ps1 "%s")
  [[ $branch ]] && echo "[$branch$(parse_git_dirty)]"
}
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '

It also adds a flash that indicates changes in your working directory.

Done

The next step is about setting up the most important tool for developing: gedit!

CC-BY (DE)

Read: RubyBuntu -3- Be one with your command line!

Topic: Paul Barry Winner RPCFN #8 Previous Topic   Next Topic Topic: Micro Web Applications For Fun And Learning

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use