6

Okay, so I want add a command to my Desktop (Or any convenient location), and whenever I run it I want it to clone the HTML5 boilerplate.

$ git clone git://github.com/paulirish/html5-boilerplate.git

And I'm tired of typing it out all the time. So how could I store my commands in a file?.

enzotib
  • 93,831

2 Answers2

18

Open your ~/.bashrc and put this at the end:

alias boil='git clone git://github.com/paulirish/html5-boilerplate.git'

or alternatively, this

boil() {
  git clone git://github.com/paulirish/html5-boilerplate.git
}

From now on, in every new terminal you can use the command boil as an alternative to your long command.

The second version is to prefer, because is more flexible being able to accept and manage parameter, for example if you define

boil() {
  [[ -z "$1" ]] && set "github.com"
  git clone git://"$1"/paulirish/html5-boilerplate.git
}

you can easily change server, if there are mirror.

# without a parameter, the function will use a default
boil
# override the default providing explicitly a server parameter
boil othergit.com

It is only an example, your fantasy surely will think up something more useful.

Obviously you can add as many functions as you need.

enzotib
  • 93,831
-3

Why not create a document with that command, and every time you wish to use it you can simply copy and paste it into the terminal.

scouser73
  • 4,334
  • 2
    -1 Because this doesn't answer the question in the way that they are looking for. – jrg Aug 03 '11 at 18:39