##### FILE: vich.pl #####
#!/usr/local/bin/perl -w
use strict;
my $whichOutput = qx` which $ARGV[0]; `;
$whichOutput =~ s/\s+$//;
stat($whichOutput);
print "Readable\n" if -r _;
print "Writable\n" if -w _;
print "Executable\n" if -x _;
print "Setuid\n" if -u _;
print "Setgid\n" if -g _;
print "Sticky\n" if -k _;
print "Text\n" if -T _;
print "Binary\n" if -B _;
if ( ( $whichOutput =~ m/^\// ) && ( -T $whichOutput ) ) {
qx`gvim -geometry 100x50 $whichOutput `;
} else {
my $myoutput = "~/tmp/vich.out";
open OUT_FILE, "> $myoutput" or die "cant open $myoutput : $!";
print OUT_FILE $whichOutput;
close OUT_FILE;
qx`gvim -geometry 100x50 $myoutput `;
}
##########################################
# END OF FILE
##########################################
Make an alias:
> alias vich vich.pl
Now instead of doing:
> which myscript
/usr/bin/myscript
> vim /usr/bin/myscript
you can just do:
> vich myscript
Just a little thing to speed things up..
No comments:
Post a Comment