aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-01-05 10:57:11 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-01-05 10:57:11 +0530
commitb5e62d7ceb3c18b7c62df472e77f4c0262f196a7 (patch)
tree2d0f131b8e7e94cb630f19df334c35704bc93e78
parente87ff1129c956da53116c4ca18ceef37b65baa92 (diff)
downloadnnn-b5e62d7ceb3c18b7c62df472e77f4c0262f196a7.tar.gz
Document picker behaviour
-rw-r--r--README.md10
-rwxr-xr-xscripts/user-scripts/copier.sh5
-rw-r--r--scripts/user-scripts/picker.sh9
3 files changed, 21 insertions, 3 deletions
diff --git a/README.md b/README.md
index f9dcea1..e6a72c7 100644
--- 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.
diff --git a/scripts/user-scripts/copier.sh b/scripts/user-scripts/copier.sh
index 391770c..a99b88b 100755
--- a/scripts/user-scripts/copier.sh
+++ b/scripts/user-scripts/copier.sh
@@ -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
diff --git a/scripts/user-scripts/picker.sh b/scripts/user-scripts/picker.sh
index 8885ed6..e69159e 100644
--- a/scripts/user-scripts/picker.sh
+++ b/scripts/user-scripts/picker.sh
@@ -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