mirror of
https://github.com/jarun/nnn.git
synced 2024-11-23 19:31:28 +00:00
Updated Basic use cases (markdown)
parent
abb8f93091
commit
163ca3be6f
|
@ -193,6 +193,35 @@ There are several ways to run commands from `nnn`:
|
||||||
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 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 to ~/.bashrc to 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 to ~/.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