From 9084440d8e7f7807725981e5757a5ae3ac2a2925 Mon Sep 17 00:00:00 2001 From: Terminator X Date: Mon, 11 Oct 2021 11:57:15 +0530 Subject: [PATCH] Updated Basic use cases (markdown) --- Basic-use-cases.md | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Basic-use-cases.md b/Basic-use-cases.md index 184da04..4390739 100644 --- a/Basic-use-cases.md +++ b/Basic-use-cases.md @@ -158,33 +158,30 @@ It has 2 methods to convert PDF to text. Please go through the script for the de ## Detached text 1. Set up a script (say `ewrap`) to open the editor in a new `tmux` split-pane or a new `xfce4-terminal` tab/window (you may want to change the terminal and the editor in the sample snippet below): + ```sh + #!/usr/bin/env sh -```sh -#!/usr/bin/env sh - -if [ -n "$TMUX" ] ; then - # tmux session running - tmux split-window -h "vim \"$*\"" -else - # Remove option --tab for new window - xfce4-terminal --tab -e "vim \"$*\"" -fi -``` - + if [ -n "$TMUX" ] ; then + # tmux session running + tmux split-window -h "vim \"$*\"" + else + # Remove option --tab for new window + xfce4-terminal --tab -e "vim \"$*\"" + fi + ``` 2. Make `ewrap` executable and drop it somewhere in your `$PATH`. 3. Set `$VISUAL` (or `$EDITOR` if you don't have `$VISUAL`) to `ewrap`: - + ```sh export VISUAL=ewrap - + ``` 4. Start `nnn` with the program option `-e`. -If you are using `nuke` as opener modify it to use `ewrap` for text files. You can also enhance `ewrap` (re-use code from `nuke`) to handle text files by file type and use the right program (e.g. w3m for html, man for man pages). That way you don't have to change the opener. - Notes: 1. **IMPORTANT:** Use the program option `-E` with detached text editing enabled. `nnn` internal operations which need to wait for the editor (like batch rename, copy/move as) wouldn't work as usual because the control returns to `nnn` after the terminal emulator is spawned. To avoid this, set `$VISUAL` as above and `$EDITOR` to a CLI editor (like `vim`). The program option forces `$EDITOR` to be used for internal operations (overriding `$VISUAL` which takes precedence otherwise). -2. If you are using a tiling window manager, the new terminal window with the editor would open beside your current window. In case of traditional window managers, the new window will be placed as per the window manager's placement configuration e.g. smart or centered on XFCE4. +2. If you are already using `nuke` as opener modify it to use `ewrap` for text files. You can also enhance `ewrap` (re-use code from `nuke`) to handle text files by file type and use the right program (e.g. w3m for html, man for man pages). That way you don't have to change the opener. +3. If you are using a tiling window manager, the new terminal window with the editor would open beside your current window. In case of traditional window managers, the new window will be placed as per the window manager's placement configuration e.g. smart or centered on XFCE4. Another options is to combine and use `nnn` with a multiplexer like `dvtm`: