Using alias to simplify clone
I want to create an alias that looks something like this:
alias getres="git clone https://github.com/user/"
The goal is that i can type "getres repository name" and get the the repository.
However as it stands now,
typing "getres repository name"
Gives me an error saying the repostiory can't be found.
git
add a comment |
I want to create an alias that looks something like this:
alias getres="git clone https://github.com/user/"
The goal is that i can type "getres repository name" and get the the repository.
However as it stands now,
typing "getres repository name"
Gives me an error saying the repostiory can't be found.
git
1
Addechoin front of thegit clonecommand so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.
– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28
1
You want a shell function for this,getres() { git clone https://github.com/user/$*; }
– jthill
Nov 24 '18 at 22:38
add a comment |
I want to create an alias that looks something like this:
alias getres="git clone https://github.com/user/"
The goal is that i can type "getres repository name" and get the the repository.
However as it stands now,
typing "getres repository name"
Gives me an error saying the repostiory can't be found.
git
I want to create an alias that looks something like this:
alias getres="git clone https://github.com/user/"
The goal is that i can type "getres repository name" and get the the repository.
However as it stands now,
typing "getres repository name"
Gives me an error saying the repostiory can't be found.
git
git
asked Nov 24 '18 at 22:26
mrmaginmrmagin
236
236
1
Addechoin front of thegit clonecommand so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.
– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28
1
You want a shell function for this,getres() { git clone https://github.com/user/$*; }
– jthill
Nov 24 '18 at 22:38
add a comment |
1
Addechoin front of thegit clonecommand so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.
– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28
1
You want a shell function for this,getres() { git clone https://github.com/user/$*; }
– jthill
Nov 24 '18 at 22:38
1
1
Add
echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28
Add
echo in front of the git clone command so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28
1
1
You want a shell function for this,
getres() { git clone https://github.com/user/$*; }– jthill
Nov 24 '18 at 22:38
You want a shell function for this,
getres() { git clone https://github.com/user/$*; }– jthill
Nov 24 '18 at 22:38
add a comment |
3 Answers
3
active
oldest
votes
This happens because getres repository name gets translated to:
git clone https://github.com/user/ repository name
which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.
The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.
see Make a Bash alias that takes a parameter?
1
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
1
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
add a comment |
What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }
add a comment |
I have just had this same problem.
For users using zsh / oh-my-zsh / iterm2 (1,2,3)
I updated my .zshrc file with the following:
function getrep(){
git clone https://github.com/USERNAME/$1.git
}
I added the ".git" at the end because I'm lazy.
Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.
(1) https://www.zsh.org/
(2) https://ohmyz.sh/
(3) https://iterm2.com/
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462887%2fusing-alias-to-simplify-clone%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
This happens because getres repository name gets translated to:
git clone https://github.com/user/ repository name
which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.
The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.
see Make a Bash alias that takes a parameter?
1
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
1
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
add a comment |
This happens because getres repository name gets translated to:
git clone https://github.com/user/ repository name
which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.
The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.
see Make a Bash alias that takes a parameter?
1
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
1
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
add a comment |
This happens because getres repository name gets translated to:
git clone https://github.com/user/ repository name
which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.
The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.
see Make a Bash alias that takes a parameter?
This happens because getres repository name gets translated to:
git clone https://github.com/user/ repository name
which means you have a space character between https://github.com/user/ and repository name which completely mess with your URL.
The solution for your problem is to create a bash script which accepts 1 parameter (the repository name) then use that script in your alias.
see Make a Bash alias that takes a parameter?
edited Nov 25 '18 at 11:39
answered Nov 24 '18 at 22:33
adrhcadrhc
470314
470314
1
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
1
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
add a comment |
1
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
1
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
1
1
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
And you can solve it by using a shell function instead of an alias.
– Daniel H
Nov 24 '18 at 22:39
1
1
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
yep, I was writing about that (while also referencing another answer) I guess while you were writing the comment
– adrhc
Nov 25 '18 at 1:10
add a comment |
What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }
add a comment |
What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }
add a comment |
What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }
What you're after is just a bit beyond the reach of aliases, which are good only for the simplest cases. You want a shell function for this, getres() { git clone https://github.com/user/$*; }
answered Nov 24 '18 at 22:40
jthilljthill
27.9k34477
27.9k34477
add a comment |
add a comment |
I have just had this same problem.
For users using zsh / oh-my-zsh / iterm2 (1,2,3)
I updated my .zshrc file with the following:
function getrep(){
git clone https://github.com/USERNAME/$1.git
}
I added the ".git" at the end because I'm lazy.
Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.
(1) https://www.zsh.org/
(2) https://ohmyz.sh/
(3) https://iterm2.com/
add a comment |
I have just had this same problem.
For users using zsh / oh-my-zsh / iterm2 (1,2,3)
I updated my .zshrc file with the following:
function getrep(){
git clone https://github.com/USERNAME/$1.git
}
I added the ".git" at the end because I'm lazy.
Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.
(1) https://www.zsh.org/
(2) https://ohmyz.sh/
(3) https://iterm2.com/
add a comment |
I have just had this same problem.
For users using zsh / oh-my-zsh / iterm2 (1,2,3)
I updated my .zshrc file with the following:
function getrep(){
git clone https://github.com/USERNAME/$1.git
}
I added the ".git" at the end because I'm lazy.
Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.
(1) https://www.zsh.org/
(2) https://ohmyz.sh/
(3) https://iterm2.com/
I have just had this same problem.
For users using zsh / oh-my-zsh / iterm2 (1,2,3)
I updated my .zshrc file with the following:
function getrep(){
git clone https://github.com/USERNAME/$1.git
}
I added the ".git" at the end because I'm lazy.
Use case is just "getrep REPNAME" from the terminal to clone into whatever current folder you are using.
(1) https://www.zsh.org/
(2) https://ohmyz.sh/
(3) https://iterm2.com/
answered Jan 12 at 17:05
Joshua JonesJoshua Jones
22210
22210
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462887%2fusing-alias-to-simplify-clone%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Add
echoin front of thegit clonecommand so that it outputs the commands it wants to execute instead of executing it, then tweak it until it produces the right command. Most likely the parameters are not used.– Lasse Vågsæther Karlsen
Nov 24 '18 at 22:28
1
You want a shell function for this,
getres() { git clone https://github.com/user/$*; }– jthill
Nov 24 '18 at 22:38