]> Sergey Matveev's repositories - nnn.git/commitdiff
F2/F5 cd/cp
authorSergey Matveev <stargrave@stargrave.org>
Thu, 26 Oct 2023 15:09:19 +0000 (18:09 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 4 Dec 2023 12:58:01 +0000 (15:58 +0300)
src/nnn.c
src/nnn.h

index 566d12c6a84512456cdf1e4287c31b934c008173..2d9f6dbc5cacdbff78f1c58192df04c4e61a5952 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -7889,6 +7889,22 @@ nochange:
                        cd = FALSE;
                        goto begin;
                }
+               case SEL_CD: // fallthrough
+               case SEL_COPY:
+                       if (!xdiraccess(plgpath)) {
+                               printwarn(&presel);
+                               goto nochange;
+                       }
+                       endselection(FALSE);
+                       tmp = sel == SEL_CD ? "!_nnn-cd*" : "!_nnn-cp";
+                       if (!run_plugin(&path, tmp, (ndents ? pdents[cur].name : NULL),
+                                                &lastname, &lastdir)) {
+                               printwait(messages[MSG_FAILED], &presel);
+                               goto nochange;
+                       }
+                       copycurname();
+                       setdirwatch();
+                       goto begin;
                case SEL_PLUGIN:
                        /* Check if directory is accessible */
                        if (!xdiraccess(plgpath)) {
index adfb83b40393c26da59cdf729651bfd5a778525f..16f5b4c95615b89d3dc6d8838f3beb4a86b8deb3 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -119,6 +119,8 @@ enum action {
        SEL_QUIT,
        SEL_QUITERR,
        SEL_VIEW,
+       SEL_COPY,
+       SEL_CD,
 #ifndef NOMOUSE
        SEL_CLICK,
 #endif
@@ -264,6 +266,10 @@ static struct key bindings[] = {
        { KEY_F(3),       SEL_VIEW },
        /* Run a plugin */
        { ';',            SEL_PLUGIN },
+       /* Call _nnn-cd */
+       { KEY_F(2),       SEL_CD },
+       /* Call _nnn-cp */
+       { KEY_F(5),       SEL_COPY },
        /* Show total size of listed selection */
        { 'S',            SEL_SELSIZE },
        /* Run command */