nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 15243186c5525ef6eb4bf065b27bc6062ee98651
parent be4460c1dad99c7e39a39411fe4d652f3b7acc0f
Author: Arun <engineerarun@gmail.com>
Date:   Sun, 17 Apr 2022 17:05:26 +0530

Merge pull request #1344 from SlIdE42/patch-1

quitcd script for Elvish shell > 0.17.0
Diffstat:
Amisc/quitcd/quitcd.elv | 39+++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+), 0 deletions(-)

diff --git a/misc/quitcd/quitcd.elv b/misc/quitcd/quitcd.elv @@ -0,0 +1,39 @@ +# Append this file to ~/.elvish/rc.elv (Elvish > 0.17.0) + +use path + +fn n {|@a| + # Block nesting of nnn in subshells + if (has-env NNNLVL) { + try { + if (>= $E:NNNLVL 1) { + echo "nnn is already running" + return + } + } catch e { + nop + } + } + + # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) + # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to + # see. + if (has-env XDG_CONFIG_HOME) { + set-env NNN_TMPFILE $E:XDG_CONFIG_HOME/nnn/.lastd + } else { + set-env NNN_TMPFILE $E:HOME/.config/nnn/.lastd + } + + # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn + # stty start undef + # stty stop undef + # stty lwrap undef + # stty lnext undef + + e:nnn $@a + + if (path:is-regular $E:NNN_TMPFILE) { + eval (slurp < $E:NNN_TMPFILE) + rm $E:NNN_TMPFILE + } +}