From 153c9344e93662984b1a5368a2722c10117db830 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Thu, 20 Aug 2026 15:13:47 +0500 Subject: nnn: update plugins --- files/.config/nnn/plugins/tnp | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 files/.config/nnn/plugins/tnp (limited to 'files/.config/nnn/plugins/tnp') diff --git a/files/.config/nnn/plugins/tnp b/files/.config/nnn/plugins/tnp new file mode 100755 index 0000000..8c484a2 --- /dev/null +++ b/files/.config/nnn/plugins/tnp @@ -0,0 +1,47 @@ +#!/usr/bin/env sh + +# Description: Only works inside a tmux session - Opens files in Neovim. +# If $NVIM is set and its server is alive, files are opened +# in that server. Otherwise, a new pane is split on the left +# and files are opened there until the nnn pane is closed. +# +# Dependencies: tmux neovim +# +# Tip: Exec nnn inside Neovim pane via a leader key +# +# vim.keymap.set("n", "n", function() +# if vim.env.TMUX then +# vim.fn.system({ +# "tmux", "split-window", "-h", +# "-c", vim.fn.getcwd(), +# "-e", "NVIM=" .. vim.v.servername, +# "exec nnn" +# }) +# end +# end) +# +# Shell: POSIX compliant +# Author: 8lackfish + +fpath="${2:+$2/}$1" + +if [ -n "$TMUX" ]; then + if [ -S "$NVIM" ]; then + svname="$NVIM" + nvim --server "$svname" --remote "$fpath" + else + id=$(tmux display-message -p '#{pane_id}.#{window_id}.#{session_id}' | tr -d '%@$') + svname="${XDG_RUNTIME_DIR:-/tmp}/nvim.nnn-tnp.$id" + if [ -S "$svname" ]; then + nvim --server "$svname" --remote "$fpath" + else + tmux split-pane -bdh "nvim --listen \"${svname}\" \"${fpath}\"" + fi + fi + until nvim --headless --server "$svname" \ + --remote-expr "execute('%argdelete')" >/dev/null 2>&1 + do :; done +else + printf "\n'%s' only works inside a tmux session" "$(basename "$0")" + printf "\n\n'Enter' to return"; read -r _ +fi -- cgit v1.2.3