Last active
August 29, 2015 14:03
-
-
Save tokuhirom/fb8689be9ab740fec985 to your computer and use it in GitHub Desktop.
repos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e() { cd $(repos-list --null | peco --null) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use Pod::Usage; | |
use File::Path; | |
use File::Basename; | |
my $base = "$ENV{HOME}/src"; | |
my $repos = shift or pod2usage; | |
if ($repos =~ /\Agit\@([^:]+):(.*)\.git\z/) { | |
clone($repos, "$1/$2"); | |
} else { | |
die "Unsupported repository type: $repos\n"; | |
} | |
exit; | |
sub clone { | |
my ($url, $path) = @_; | |
mkpath(dirname($path)); | |
exec('git', 'clone', $url, "$base/$path"); | |
die $!; | |
} | |
__END__ | |
=head1 SYNOPSIS | |
% repos-clone [email protected]:tokuhirom/nanobench.git | |
=head1 DESCRIPTION | |
List up cloned repositories from ~/src/. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
my $p = | |
Getopt::Long::Parser->new( | |
config => [qw(posix_default no_ignore_case auto_help)]); | |
$p->getoptions('null!' => \my $null,); | |
my $base = "$ENV{HOME}/src"; | |
for my $d (glob("$base/*/*/*")) { | |
next unless -d $d; | |
(my $base = $d) =~ s!^$base/!!; | |
if ($null) { | |
print "$base\0$d\n"; | |
} else { | |
print "$d\n"; | |
} | |
} | |
__END__ | |
=head1 DESCRIPTION | |
List up cloned repositories from ~/src/. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment