]> Sergey Matveev's repositories - nnn.git/commitdiff
Show path in short form
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 8 Sep 2019 09:43:44 +0000 (15:13 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 8 Sep 2019 09:58:31 +0000 (15:28 +0530)
src/nnn.c

index 844a3a50995d8c4baf2af8db427f95c2b3e476d5..b820d0dba22a626164e5e23adb4b11c272c956f2 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -3154,6 +3154,7 @@ static void redraw(char *path)
        int i, attrs;
        char buf[12];
        char c;
+       char *ptr = path, *base = xbasename(path);
 
        --lastln;
 
@@ -3206,7 +3207,23 @@ static void redraw(char *path)
        /* No text wrapping in cwd line, store the truncating char in c */
        c = path[ncols - 11];
        path[ncols - 11] = '\0';
-       printw("%s\n\n", path);
+
+       /* Print path */
+       if (base - ptr <= 1)
+               printw("%s\n\n", path);
+       else {
+               base = base - 1;
+               while (ptr < base) {
+                       if (*ptr == '/') {
+                               addch(*ptr);
+                               addch(*(++ptr));
+                       }
+                       ++ptr;
+               }
+
+               printw("/%s\n\n", base + 1);
+       }
+
        attroff(A_UNDERLINE);
        path[ncols - 11] = c; /* Restore c */