From de7fcc579246a9f7b294d7f6508714bea23b86ec Mon Sep 17 00:00:00 2001 From: Terminator X Date: Sat, 23 Oct 2021 03:36:47 +0530 Subject: [PATCH] Updated Concepts (markdown) --- Concepts.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Concepts.md b/Concepts.md index 2171e1a..b4709ec 100644 --- a/Concepts.md +++ b/Concepts.md @@ -284,6 +284,36 @@ 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. +#### Copy command from spawned shell to native command 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 Ctrl-Shift-V. + +```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 +``` + ## 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.