Skip to content

Instantly share code, notes, and snippets.

@shalk
Last active October 12, 2019 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shalk/740ebfdc30527174d2fe560155e00161 to your computer and use it in GitHub Desktop.
Save shalk/740ebfdc30527174d2fe560155e00161 to your computer and use it in GitHub Desktop.
when clone git repo from http or git protocol ,it will create directory in user_home; egg: git-clone-helper.pl https://github.com/github/fetch , clone into directory /home/me/code/github.com/github/fetch
#!/usr/bin/env perl
use feature qw(say);
$num_args = $#ARGV + 1;
if ($num_args < 1) {
print "usage: git-clone url" ;
exit
}
$addr = $ARGV[0];
if ( $addr =~ /(?:http:\/\/|https:\/\/|git@)([^:\/]+)(?:\/|:)([^:\/]+)\/([^:\/\.]+)(.git)?/ ) {
my $url=$1;
my $dir1=$2;
my $dir2=$3;
chdir;
mkdir "code";
chdir "code";
mkdir $url;
chdir $url;
mkdir $dir1;
chdir $dir1;
say `pwd`;
say "git clone $addr";
`git clone $addr`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment