问题
When I enter a git repo url in terminal it says:
% https://github.com/chmln/sd.git
zsh: no such file or directory: https://github.com/chmln/sd.git
I want https://github.com/chmln/sd.git to act as a command which will
git clone https://github.com/chmln/sd.git
cd sd
How can I do that?
回答1:
OP provides more detail on use case. Worth addressing this use case specifically. When a command (git clone in this case) should be assumed, consider ERR trap with the BASH_COMMAND (or $_)
trap 'try_gc' ERR
function try_gc {
local x=$BASH_COMMAND
if [[ "$x" = https://* ]] ; then git clone "$x"; fi;
}
来源:https://stackoverflow.com/questions/63099402/git-url-as-a-command