Created
July 31, 2012 15:58
-
-
Save jnbek/3218045 to your computer and use it in GitHub Desktop.
~/bin/dirty
This file contains 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
# I want a tool that tells me what my modified files are, whether I'm in a Subversion or Git project. | |
# I want to be able to say vim $(dirty) | |
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
my @lines = qx/svn status 2>&1/; | |
exit if @lines == 0; | |
chomp @lines; | |
my $first = $lines[0]; | |
if ( $first !~ /svn: warning: .+ not a working copy/ ) { | |
@lines = grep { !/^[?]/ } @lines; # Ignore unversioned files | |
s/^........// for @lines; | |
print "$_\n" for @lines; | |
exit; | |
} | |
@lines = qx/git status --short --untracked-files=no/; | |
chomp @lines; | |
s/^...// for @lines; | |
print "$_\n" for @lines; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment