diff --git a/Concepts.md b/Concepts.md index c35c414..15e9106 100644 --- a/Concepts.md +++ b/Concepts.md @@ -256,6 +256,32 @@ The following special variables can be accessed from the command prompt or a spa E.g. to copy the hovered file in context 1 to the directory open in context 3, run `cp "$f1" "$d3"`. +Selection can be accessed from the command prompt: + +| Variable | Substitution | +|:---:| --- | +| `%j` | repeat the command with `%j` substituted by each selected file path (all occurrances of`%j` are substituted) | +| `%J` | run the command only once with the last `%J` substituted by all selected file paths | + +E.g. + +Look up a string in each file in selection: + +```sh +printf "Searching for string in %s\n" "%j"; grep "string" "%j" +``` + +Archive all files in selection: + +```sh +tar uvf archive.tar %J +``` + +Notes: + +1. You can only use either `%j` or `%J` inside a single command. If both are encountered the prompt will close. No command will be executed. +2. When using `%J` `nnn` won't quote the file paths from selection. Quoting `%J` will just place quotes around the entire selection, it won't quote each item individually. + ## Design `nnn` (the core C utility) is, generally speaking, _feature-restricted_. It includes features which you _really_ need so it can remain light enough to finish your workflow accurately before your train of thought is lost.