瀏覽代碼

Document picker behaviour

master
Arun Prakash Jana 5 年之前
父節點
當前提交
b5e62d7ceb
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: A75979F35C080412
共有 3 個文件被更改,包括 21 次插入3 次删除
  1. +10
    -0
      README.md
  2. +5
    -0
      scripts/user-scripts/copier.sh
  3. +6
    -3
      scripts/user-scripts/picker.sh

+ 10
- 0
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). 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 #### run custom scripts


`nnn` can invoke custom scripts with the currently selected file name as argument 1. `nnn` can invoke custom scripts with the currently selected file name as argument 1.


+ 5
- 0
scripts/user-scripts/copier.sh 查看文件

@@ -1,5 +1,10 @@
#!/usr/bin/env sh #!/usr/bin/env sh


# Description: Copy selection to clipboard
#
# Shell: generic
# Author: Arun Prakash Jana

# Linux # Linux
cat ~/.nnncp | xargs -0 | xsel -bi cat ~/.nnncp | xargs -0 | xsel -bi




+ 6
- 3
scripts/user-scripts/picker.sh 查看文件

@@ -2,7 +2,7 @@


# Description: Pick files and pipe the line-separated list to another utility # Description: Pick files and pipe the line-separated list to another utility
# #
# Shell: sh
# Shell: generic
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
# #
# Usage: # Usage:
@@ -17,5 +17,8 @@
# NOTE: This use case is limited to picking files, other functionality may not work as expected. # NOTE: This use case is limited to picking files, other functionality may not work as expected.


nnn -p /tmp/picked 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

Loading…
取消
儲存