mirror of
https://github.com/jarun/nnn.git
synced 2024-11-27 13:21:29 +00:00
Updated Basic use cases (markdown)
parent
c5bd60766b
commit
bfce9e3e49
|
@ -192,39 +192,9 @@ Another options is to combine and use `nnn` with a multiplexer like `dvtm`:
|
||||||
There are several ways to run commands from `nnn`:
|
There are several ways to run commands from `nnn`:
|
||||||
|
|
||||||
1. Launch a shell within the current directory. This is your regular shell.
|
1. Launch a shell within the current directory. This is your regular shell.
|
||||||
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.
|
2. Use the prompt key to show the [native command prompt](https://github.com/jarun/nnn/wiki/Concepts#native-command-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.
|
||||||
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)).
|
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
|
|
||||||
|
|
||||||
The prompt (non-readline `nnn`-internal one) can remember the last executed command. Sometimes it may be desirable copy a command from shell history to the prompt. Keybinds can be configured to copy a command from bash/zsh prompt to the system clipboard. You can use these at the subshell prompt and paste the command at the prompt with <kbd>Ctrl-Shift-V</kbd>.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# bash: add in ~/.bashrc
|
|
||||||
# copy current line to clipboard with ^]
|
|
||||||
|
|
||||||
if [[ -n $DISPLAY ]]; then
|
|
||||||
copy_line_to_x_clipboard () {
|
|
||||||
printf %s "$READLINE_LINE" | xsel -ib
|
|
||||||
}
|
|
||||||
bind -x '"\C-]": copy_line_to_x_clipboard'
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
# zsh: add in ~/.zshrc
|
|
||||||
# copy current line to clipboard with ^U
|
|
||||||
|
|
||||||
if [[ -n $DISPLAY ]]; then
|
|
||||||
x-kill-whole-line () {
|
|
||||||
zle kill-whole-line
|
|
||||||
print -rn -- "$CUTBUFFER" | xsel -ib
|
|
||||||
}
|
|
||||||
zle -N x-kill-whole-line
|
|
||||||
bindkey '\C-u' x-kill-whole-line
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Shell depth indicator
|
#### 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:
|
If you use `!` to spawn a shell in the current directory and your shell is bash or zsh, it could be nice to add:
|
||||||
|
|
Loading…
Reference in a new issue