aboutsummaryrefslogtreecommitdiff
path: root/.nnnrc
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-11-23 08:37:59 +0800
committerGuangxiong Lin <[email protected]>2022-11-23 08:37:59 +0800
commit652ba26f32b55b6f0e47f746d3c7a11d96f3eb97 (patch)
tree122c5241b1de73eb09be197f0be5307b6b9ecaac /.nnnrc
parent5835862da892223d7c7047723c0d37775deb7487 (diff)
downloaddotfiles-652ba26f32b55b6f0e47f746d3c7a11d96f3eb97.tar.gz
dotfiles-652ba26f32b55b6f0e47f746d3c7a11d96f3eb97.tar.bz2
dotfiles-652ba26f32b55b6f0e47f746d3c7a11d96f3eb97.zip
Update nnn config
Diffstat (limited to '.nnnrc')
-rwxr-xr-x.nnnrc25
1 files changed, 18 insertions, 7 deletions
diff --git a/.nnnrc b/.nnnrc
index 3250cf5..b3cf992 100755
--- a/.nnnrc
+++ b/.nnnrc
@@ -4,13 +4,24 @@ if [ ! -d $HOME/.config/nnn/plugins ]; then
curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh
fi
-# To support cd on quit (Ctrl-G)
-# NOTE: It will add a function `n` and ONLY work when typing `n` instead
-# of `nnn`.
-if [ -f /usr/share/nnn/quitcd/quitcd.bash_zsh ]; then
- source /usr/share/nnn/quitcd/quitcd.bash_zsh
-fi
-
export NNN_PLUG='f:fzcd;v:imgview;j:autojump;p:preview-tui'
[ -f /usr/bin/trash ] && export NNN_TRASH=1
export NNN_FIFO=/tmp/nnn.fifo
+
+# To support cd on quit (Ctrl-G)
+# NOTE: The quitcd ONLY work when typing `n` instead of `nnn`.
+n () {
+ if [[ "${NNNLVL:-0}" -ge 1 ]]; then
+ echo "nnn is already running"
+ return
+ fi
+
+ NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
+
+ \nnn "$@"
+
+ if [ -f "$NNN_TMPFILE" ]; then
+ . "$NNN_TMPFILE"
+ rm -f "$NNN_TMPFILE" > /dev/null
+ fi
+}