Updated Basic use cases (markdown)

Terminator X 2021-10-11 11:57:15 +05:30
parent 7f7567f049
commit 9084440d8e

@ -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`: