Commit Diff


commit - c68761153b8b771dbd18c015f8bf3b174c5f21cc
commit + 15d7cd85a653b5bc67e16ace1d9c4ef4d3fc257e
blob - b87b5d88206d4969056d571eba14a26f78cdb2f6
blob + ef85e2560cdf02872288a58e501a8754278077cc
--- config.h
+++ config.h
@@ -13,6 +13,7 @@
 #define RVK_CD_DOWN     "l"
 #define RVK_CD_UP       "h"
 #define RVK_HOME        "H"
+#define RVK_TARGET      "t"
 #define RVK_REFRESH     "r"
 #define RVK_SHELL       "^M"
 #define RVK_VIEW        " "
blob - e3bf98be63ab565013599a36dc542744ec398d4a
blob + 63751dbd48892d0cacc6840151093544f7f9e578
--- rover.c
+++ rover.c
@@ -14,6 +14,7 @@
 #include <locale.h>     /* setlocale(), LC_ALL */
 #include <unistd.h>     /* chdir(), getcwd(), read(), close(), ... */
 #include <dirent.h>     /* DIR, struct dirent, opendir(), ... */
+#include <libgen.h>
 #include <sys/stat.h>
 #include <fcntl.h>      /* open() */
 #include <sys/wait.h>   /* waitpid() */
@@ -1083,6 +1084,26 @@ main(int argc, char *argv[])
             if (CWD[strlen(CWD) - 1] != '/')
                 strcat(CWD, "/");
             cd(1);
+        } else if (!strcmp(key, RVK_TARGET)) {
+            char *bname, first;
+            int is_dir = S_ISDIR(EMODE(ESEL));
+            ssize_t len = readlink(ENAME(ESEL), BUF1, BUFLEN-1);
+            if (len == -1) continue;
+            BUF1[len] = '\0';
+            realpath(BUF1, CWD);
+            len = strlen(CWD);
+            if (CWD[len - 1] == '/')
+                CWD[len - 1] = '\0';
+            bname = strrchr(CWD, '/') + 1;
+            first = *bname;
+            *bname = '\0';
+            cd(1);
+            *bname = first;
+            if (is_dir)
+                strcat(CWD, "/");
+            try_to_sel(bname);
+            *bname = '\0';
+            update_view();
         } else if (!strcmp(key, RVK_REFRESH)) {
             reload();
         } else if (!strcmp(key, RVK_SHELL)) {