Sunday, April 28, 2024
17
rated 0 times [  17] [ 0]  / answers: 1 / hits: 8185  / 2 Years ago, tue, november 30, 2021, 1:35:30

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


More From » command-line

 Answers
6

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.


[#44003] Thursday, December 2, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
theurn

Total Points: 30
Total Questions: 110
Total Answers: 111

Location: Bahrain
Member since Fri, Sep 16, 2022
2 Years ago
theurn questions
Tue, Apr 5, 22, 14:18, 2 Years ago
Mon, Feb 14, 22, 16:29, 2 Years ago
Sat, Apr 8, 23, 05:26, 1 Year ago
Tue, Jan 10, 23, 23:59, 1 Year ago
Fri, Apr 8, 22, 01:36, 2 Years ago
;