git url as a command

六月ゝ 毕业季﹏ 提交于 2020-08-06 07:13:03

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!