From 450fc7d07b50d9c882841cc277e4ecafe6f14fa2 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 26 Oct 2023 18:09:19 +0300 Subject: [PATCH] F2/F5 cd/cp --- src/nnn.c | 16 ++++++++++++++++ src/nnn.h | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/nnn.c b/src/nnn.c index 566d12c6..2d9f6dbc 100644 --- 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)) { diff --git a/src/nnn.h b/src/nnn.h index adfb83b4..16f5b4c9 100644 --- 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 */ -- 2.48.1