From a40d29ba9f5673523dfdf28e17d448a3cb8da1f8 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sun, 14 Jan 2018 01:43:30 +0530 Subject: Support multiple file path copy Design overview: We are introducing multiple file path copy as a mode which can be toggled using the keybind `^Y`. `^K` works as the individual entry selector. If the user wants to select a range, (s)he can press `^Y` on the first entry and `^Y` on the last entry. We subscribe to notifications, so we need a fail-proof way to detect changes in the directory contents. For example, if a file is deleted, it becomes difficult to get the names of all the files in a range containing that file. If the file is on a range boundary it would lead to wrong calculations. To handle this the right way we use CRC8 checksum of all the visible entries in the directory. The checksum is calculated based on the file information buffer. If the CRC changes on a redraw(), we reset the multi-select mode. New line (`\n`) works as the delimiter between file paths. Note that you may have to disable IFS in the `NNN_COPIER` script to show file paths separated by spaces. --- nnn.1 | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'nnn.1') diff --git a/nnn.1 b/nnn.1 index 4c2a3cb..e1bbfee 100644 --- a/nnn.1 +++ b/nnn.1 @@ -102,6 +102,8 @@ List files in archive Extract archive in current directory .It Ic ^K Invoke file path copier +.It Ic ^Y +Toggle multiple file path copy mode .It Ic ^L Force a redraw, clear rename or filter prompt .It Ic \&? @@ -171,12 +173,21 @@ instructions. Filters support regexes to instantly (search-as-you-type) list the matching entries in the current directory. .Pp -There are 3 ways to reset a filter: (1) pressing \fI^L\fR (at the new/rename -prompt \fI^L\fR followed by \fIEnter\fR discards all changes and exits prompt), -(2) a search with no matches or (3) an extra backspace at the filter prompt (like vi). +There are 3 ways to reset a filter: .Pp -Common use cases: (1) To list all matches starting with the filter expression, -start the expression with a '^' (caret) symbol. (2) Type '\\.mkv' to list all MKV files. +(1) pressing \fI^L\fR (at the new/rename prompt \fI^L\fR followed by \fIEnter\fR +discards all changes and exits prompt), +.br +(2) a search with no matches or +.br +(3) an extra backspace at the filter prompt (like vi). +.Pp +Common use cases: +.Pp +(1) To list all matches starting with the filter expression, start the expression +with a '^' (caret) symbol. +.br +(2) Type '\\.mkv' to list all MKV files. .Pp If .Nm @@ -184,6 +195,18 @@ is invoked as root the default filter will also match hidden files. .Pp In the \fInavigate-as-you-type\fR mode directories are opened in filter mode, allowing continuous navigation. Works best with the \fBarrow keys\fR. +.Sh MULTI-COPY MODE +The absolute path of a single file can be copied to clipboard by pressing \fI^K\fR if +NNN_COPIER is set (see ENVIRONMENT section below). +.Pp +To copy multiple file paths the multi-copy mode should be enabled using \fI^Y\fR. +In this mode it's possible to +.Pp +(1) select multiple files one by one by pressing \fI^K\fR on each entry; or, +.br +(2) navigate to another file in the same directory to select a range of files. +.Pp +Pressing \fI^Y\fR again copies the paths to clipboard and exits the multi-copy mode. .Sh ENVIRONMENT The SHELL, EDITOR and PAGER environment variables take precedence when dealing with the !, e and p commands respectively. @@ -214,6 +237,8 @@ screensaver. ------------------------------------- #!/bin/sh + # comment the next line to convert newlines to spaces + IFS= echo -n $1 | xsel --clipboard --input ------------------------------------- .Ed -- cgit v1.2.3-70-g09d2