holygeek / git-number

Use numbers for dealing with files in git
ISC License
281 stars 25 forks source link

FR: Implement option to generate absolute path #38

Open KES777 opened 6 years ago

KES777 commented 6 years ago
diff --git a/git-number b/git-number
index 221ba8e..d5f7988 100755
--- a/git-number
+++ b/git-number
@@ -141,10 +141,10 @@ while (scalar @ARGV) {
     }

     if ( $arg =~ m/^[0-9][0-9]*$/ ) {
-        push @args, split("\n", `git-list $arg`);
+        push @args, map{"$ENV{PWD}/$_"} split("\n", `git-list $arg`);
         $converted=1;
     } elsif ( $arg =~ m/^[0-9][0-9]*-[0-9][0-9]*$/ ) {
-        push @args, split("\n", `git-list $arg`);
+        push @args, map{"$ENV{PWD}/$_"} split("\n", `git-list $arg`);
         $converted=1;
     } else {
         if (index($arg, ' ') != -1) {
kes@work ~/work/projects/github-forks/git-number $ 

With this patch I force git-number to generate absolute path:

$ ge 2 # with patch
subl /home/kes/s/lib/App/Controller/ConnConfig.pm
$ ge 2  # without patch
subl lib/App/Controller/ConnConfig.pm 

This allows me to workaround problem when sublime text editor expand ~s symlink to full absolute path.

Currently I just expand path unconditionally

holygeek commented 6 years ago

Instead of modifying git-number, you can write a wrapper script to do this:

#!/bin/sh
subl $(git list $*|sed "s|^$PWD/|")

Though it breaks if the filename contains spaces.