mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Update docs
This commit is contained in:
parent
5bd2833b12
commit
db8d51c504
172
README.md
172
README.md
|
@ -61,26 +61,6 @@ We need contributors. Please visit the [ToDo list](https://github.com/jarun/nnn/
|
||||||
- [Help](#help)
|
- [Help](#help)
|
||||||
- [Quickstart](#quickstart)
|
- [Quickstart](#quickstart)
|
||||||
- [How to](#how-to)
|
- [How to](#how-to)
|
||||||
- [add bookmarks](#add-bookmarks)
|
|
||||||
- [copy file paths](#copy-file-paths)
|
|
||||||
- [to clipboard](#to-clipboard)
|
|
||||||
- [get selection manually](#get-selection-manually)
|
|
||||||
- [cd on quit](#cd-on-quit)
|
|
||||||
- [(neo)vim plugin](#neovim-plugin)
|
|
||||||
- [file picker](#file-picker)
|
|
||||||
- [run custom scripts](#run-custom-scripts)
|
|
||||||
- [sample scripts](#sample-scripts)
|
|
||||||
- [launch applications](#launch-applications)
|
|
||||||
- [change dir color](#change-dir-color)
|
|
||||||
- [integrate patool](#integrate-patool)
|
|
||||||
- [remote transfers](#remote-transfers)
|
|
||||||
- [prompt shortcuts](#prompt-shortcuts)
|
|
||||||
- [set idle timeout](#set-idle-timeout)
|
|
||||||
- [hot-plugged drives](#hot-plugged-drives)
|
|
||||||
- [tmux configuration](#tmux-configuration)
|
|
||||||
- [BSD terminal issue](#bsd-terminal-issue)
|
|
||||||
- [restrict file open](#restrict-file-open)
|
|
||||||
- [restrict 0-byte files](#restrict-0-byte-files)
|
|
||||||
- [Why fork?](#why-fork)
|
- [Why fork?](#why-fork)
|
||||||
- [Mentions](#mentions)
|
- [Mentions](#mentions)
|
||||||
- [Developers](#developers)
|
- [Developers](#developers)
|
||||||
|
@ -405,157 +385,7 @@ To lookup keyboard shortcuts at runtime, press <kbd>?</kbd>.
|
||||||
|
|
||||||
#### HOW TO
|
#### HOW TO
|
||||||
|
|
||||||
#### add bookmarks
|
Please visit the [How to](https://github.com/jarun/nnn/wiki/How-to) wiki page.
|
||||||
|
|
||||||
Set environment variable `NNN_BMS` as a string of `key_char:location` pairs (max 10) separated by semicolons (`;`):
|
|
||||||
|
|
||||||
export NNN_BMS='d:~/Documents;u:/home/user/Cam Uploads;D:~/Downloads/'
|
|
||||||
|
|
||||||
NOTE: Bookmark keys should be single-character to use them in combination with the Leader key.
|
|
||||||
|
|
||||||
#### copy file paths
|
|
||||||
|
|
||||||
##### to clipboard
|
|
||||||
|
|
||||||
Along with default copy, `nnn` can pipe the absolute path of the current file or multiple files to a copier script. For example, you can use `xsel` on Linux or `pbcopy` on macOS. Here's a sample [copier script](https://github.com/jarun/nnn/blob/master/scripts/user-scripts/copier.sh).
|
|
||||||
|
|
||||||
To inform `nnn` of the executable copier script location:
|
|
||||||
|
|
||||||
export NNN_COPIER="/path/to/copier.sh"
|
|
||||||
|
|
||||||
##### get selection manually
|
|
||||||
|
|
||||||
NOTE: In the following examples we assume the copy file is at `/home/user/.nnncp`.
|
|
||||||
|
|
||||||
The file paths are `NUL`-terminated, so additional processing is required to make them usable.
|
|
||||||
|
|
||||||
To get a space-separated list of the file paths in selection:
|
|
||||||
|
|
||||||
cat /home/user/.nnncp | xargs -0 echo
|
|
||||||
|
|
||||||
To get a newline-separated list of the file paths in selection:
|
|
||||||
|
|
||||||
# bash/zsh
|
|
||||||
ls -ltr `cat /home/user/.nnncp | tr '\0' '\n'`
|
|
||||||
ls -ltr $(cat /home/user/.nnncp | tr '\0' '\n')
|
|
||||||
|
|
||||||
# fish
|
|
||||||
ls -ltr (cat /home/user/.nnncp | tr '\0' '\n')
|
|
||||||
|
|
||||||
An alias may be handy, e.g. when you want to copy selection at the _run a command_ prompt:
|
|
||||||
|
|
||||||
alias ncp="cat /home/user/.nnncp | tr '\0' '\n'"
|
|
||||||
|
|
||||||
so you can easily handle files together:
|
|
||||||
|
|
||||||
# bash/zsh
|
|
||||||
ls -ltr `ncp`
|
|
||||||
ls -ltr $(ncp)
|
|
||||||
|
|
||||||
# fish
|
|
||||||
ls -ltr (ncp)
|
|
||||||
|
|
||||||
To get the list in a file:
|
|
||||||
|
|
||||||
ncp > out.txt
|
|
||||||
|
|
||||||
#### cd on quit
|
|
||||||
|
|
||||||
To quit `nnn` and switch to the directory last opened follow the instructions below.
|
|
||||||
|
|
||||||
Pick the appropriate file for your shell from [`scripts/quitcd`](scripts/quitcd) and add the contents to your shell's rc file. You'll need to spawn a new shell for the change to take effect. You should start `nnn` as `n` (or modify the function name to something else). To change directory on quit press `^G` while exiting.
|
|
||||||
|
|
||||||
As you might notice, `nnn` uses the environment variable `NNN_TMPFILE` to write the last visited directory path. You can change it.
|
|
||||||
|
|
||||||
#### (neo)vim plugin
|
|
||||||
|
|
||||||
`nnn` can be used as a file picker/chooser within vim or neovim. Find the plugin [here](https://github.com/mcchrish/nnn.vim).
|
|
||||||
|
|
||||||
#### file picker
|
|
||||||
|
|
||||||
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 in the current directory with the currently selected file name as argument 1.
|
|
||||||
|
|
||||||
Export the absolute path to the directory with your scripts or a single script:
|
|
||||||
|
|
||||||
export NNN_SCRIPT=/home/user/scripts
|
|
||||||
OR
|
|
||||||
export NNN_SCRIPT=/usr/local/bin/nscript.sh
|
|
||||||
|
|
||||||
Press <kbd>R</kbd> to run the script in the current directory. You can also use this key to cancel choosing a script from the script directory and get back to the original directory.
|
|
||||||
|
|
||||||
##### sample scripts
|
|
||||||
|
|
||||||
Sample scripts for use cases like sxiv or fzy integration are under [user-scripts](https://github.com/jarun/nnn/tree/master/scripts/user-scripts). Feel free to contribute yours!
|
|
||||||
|
|
||||||
#### launch applications
|
|
||||||
|
|
||||||
Applications can be launched from the _run a command_ prompt. Use `&` to launch GUI applications in the background.
|
|
||||||
|
|
||||||
#### change dir color
|
|
||||||
|
|
||||||
The default color for directories is blue. Option `-c` accepts color codes from 0 to 7 to use a different color:
|
|
||||||
|
|
||||||
0-black, 1-red, 2-green, 3-yellow, 4-blue, 5-magenta, 6-cyan, 7-white
|
|
||||||
|
|
||||||
Any other value disables colored directories.
|
|
||||||
|
|
||||||
#### integrate patool
|
|
||||||
|
|
||||||
On systems where `atool` is not available but `patool` is, drop two copies of the Python3 script [natool](https://github.com/jarun/nnn/tree/master/scripts/natool) as `atool` and `apack` somewhere in `$PATH`.
|
|
||||||
|
|
||||||
#### remote transfers
|
|
||||||
|
|
||||||
lftp can be used with `nnn` for automated remote transfers or copying a selection to a server. Visit the [wiki page](https://github.com/jarun/nnn/wiki/simplify-remote-transfers-with-lftp) for more details on the integration.
|
|
||||||
|
|
||||||
#### prompt shortcuts
|
|
||||||
|
|
||||||
The prompts (expect filter prompt) support some bash-like command-line shortcuts - <kbd>^A</kbd>, <kbd>^E</kbd>, <kbd>^U</kbd>.
|
|
||||||
|
|
||||||
Key <kbd>^L</kbd> clears and <kbd>Esc</kbd> exits _any_ prompt.
|
|
||||||
|
|
||||||
#### set idle timeout
|
|
||||||
|
|
||||||
The terminal locker is disabled by default. To set the wait time in seconds, use environment variable `NNN_IDLE_TIMEOUT`.
|
|
||||||
|
|
||||||
#### hot-plugged drives
|
|
||||||
|
|
||||||
Enable volume management in your DE file manager and set removable drives or media to be auto-mounted when inserted. Then visit the usual mount point location (`/mnt` or `/media/user`) in `nnn`.
|
|
||||||
|
|
||||||
#### tmux configuration
|
|
||||||
|
|
||||||
`nnn` might not handle keypresses correctly when used with tmux (see issue #104 for more details). Set `TERM=xterm-256color` to address it.
|
|
||||||
|
|
||||||
#### BSD terminal issue
|
|
||||||
|
|
||||||
By default in OpenBSD & FreeBSD, `stty` maps <kbd>^Y</kbd> to `DSUSP`. This means that typing <kbd>^Y</kbd> will suspend `nnn` as if you typed <kbd>^Z</kbd> (you can bring `nnn` back to the foreground by issuing `fg`) instead of entering multi-copy mode. You can check this with `stty -a`. If it includes the text `dsusp = ^Y`, issuing `stty dsusp undef` will disable this `DSUSP` and let `nnn` receive the <kbd>^Y</kbd> instead.
|
|
||||||
|
|
||||||
#### restrict file open
|
|
||||||
|
|
||||||
In order to disable opening files on accidental navigation key (<kbd>→</kbd> or <kbd>l</kbd>) press:
|
|
||||||
|
|
||||||
export NNN_RESTRICT_NAV_OPEN=1
|
|
||||||
|
|
||||||
Use <kbd>Enter</kbd> to open files.
|
|
||||||
|
|
||||||
#### restrict 0-byte files
|
|
||||||
|
|
||||||
Restrict opening 0-byte files due to [unexpected behaviour](https://github.com/jarun/nnn/issues/187); use _edit_ or _open with_ to open the file.
|
|
||||||
|
|
||||||
export NNN_RESTRICT_0B=1
|
|
||||||
|
|
||||||
#### WHY FORK?
|
#### WHY FORK?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue