1
1
mirror of https://github.com/jarun/nnn.git synced 2024-11-23 00:26:00 +03:00

Updated Basic use cases (markdown)

Terminator X 2021-10-23 03:29:52 +05:30
parent 8df5f3cb27
commit 275ce1d775

@ -192,7 +192,7 @@ Another options is to combine and use `nnn` with a multiplexer like `dvtm`:
There are several ways to run commands from `nnn`:
1. Launch a shell within the current directory. This is your regular shell.
2. Use the prompt key to show the prompt and enter your command. The commands are invoked using the `$SHELL` so you can use commands, aliases (in `~/.zshenv` for zsh), environment variables, pipes, redirections.
2. Use the prompt key to show the [native command prompt](https://github.com/jarun/nnn/wiki/Concepts#prompts) and enter your command. The commands are invoked using the `$SHELL` so you can use commands, aliases (in `~/.zshenv` for zsh), environment variables, pipes, redirections.
3. You can also assign keys to arbitrary non-background cli commands (non-shell-interpreted) you use frequently and invoke like plugins. ([instructions](https://github.com/jarun/nnn/tree/master/plugins#running-commands-as-plugin)).
#### Copy command from spawned shell to prompt
@ -225,28 +225,6 @@ if [[ -n $DISPLAY ]]; then
fi
```
#### Executing a command for each file in selection
While in the prompt you are able to execute a command with each item from the selection as its arguments. Etiher one by one or all at once.
To execute a command on a per file basis place `%j` where the file path should be placed. The following example searches for a string in each file.
```sh
printf "Searching for string in %s\n" "%j"; grep "string" "%j"
```
To execute a command with the entire selection as arguments place `%J` where the file paths should be placed. The following example updates a tar archive with the entire selection.
```sh
tar uvf archive.tar %J
```
There are some limitations when using `%j` and `%J`:
* You can use multiple `%j` inside a single command.
* You can only use one `%J` inside a single command. If multiple `%J` are used only the last one will be replaced with the selection.
* 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.
* 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.
#### Shell depth indicator
If you use `!` to spawn a shell in the current directory and your shell is bash or zsh, it could be nice to add: