]> Sergey Matveev's repositories - nnn.git/commitdiff
Document picker behaviour
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 5 Jan 2019 05:27:11 +0000 (10:57 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 5 Jan 2019 05:27:11 +0000 (10:57 +0530)
README.md
scripts/user-scripts/copier.sh
scripts/user-scripts/picker.sh

index f9dcea14ef630881f83c99cb0b14767b551f2c31..e6a72c73ec869bb0344e2805c7d9863ea744d9db 100644 (file)
--- a/README.md
+++ b/README.md
@@ -465,6 +465,16 @@ As you might notice, `nnn` uses the environment variable `NNN_TMPFILE` to write
 
 To use `nnn` as a file picker and redirect the output to other programs, use [picker.sh](https://github.com/jarun/nnn/blob/master/scripts/user-scripts/picker.sh).
 
+Ways to pick files:
+
+- use selection and press <kbd>q</kbd> to quit
+- press <kbd>Enter</kbd> to pick any earlier selection and the current entry (to avoid selecting the last file in the selection twice, press <kbd>q</kbd> instead).
+
+Notes:
+
+- pressing <kbd>Enter</kbd> on a directory enters it; when trying to pick a directory, e.g. to pipe to `cd`, use single file selection and press <kbd>q</kbd>
+- to discard selection and quit, press <kbd>^G</kbd>
+
 #### run custom scripts
 
 `nnn` can invoke custom scripts with the currently selected file name as argument 1.
index 391770cb2a5a3665b5a3804e15cc16b558003a0e..a99b88bbda45d8668407bdbc7afadd5177041548 100755 (executable)
@@ -1,5 +1,10 @@
 #!/usr/bin/env sh
 
+# Description: Copy selection to clipboard
+#
+# Shell: generic
+# Author: Arun Prakash Jana
+
 # Linux
 cat ~/.nnncp | xargs -0 | xsel -bi
 
index 8885ed6b40708ff1a237fe2037c3133359dfa223..e69159e7843e50a01d27ba2e60ec7d935ea77a7c 100644 (file)
@@ -2,7 +2,7 @@
 
 # Description: Pick files and pipe the line-separated list to another utility
 #
-# Shell: sh
+# Shell: generic
 # Author: Arun Prakash Jana
 #
 # Usage:
@@ -17,5 +17,8 @@
 # NOTE: This use case is limited to picking files, other functionality may not work as expected.
 
 nnn -p /tmp/picked
-cat /tmp/picked | tr '\0' '\n'
-rm /tmp/picked
+
+if [ -f /tmp/picked ]; then
+    cat /tmp/picked | tr '\0' '\n'
+    rm /tmp/picked
+fi