Skip to content

Instantly share code, notes, and snippets.

@jnbek
Created July 31, 2012 15:58
Show Gist options
  • Save jnbek/3218045 to your computer and use it in GitHub Desktop.
Save jnbek/3218045 to your computer and use it in GitHub Desktop.
~/bin/dirty
# 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