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?.

2 Answers 2

17

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
boid othergit.com

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

Obviously you can add as many functions as you need.

-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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.