]> Sergey Matveev's repositories - nnn.git/commitdiff
Block nesting of nnn instances
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 17 Nov 2019 09:03:30 +0000 (14:33 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 17 Nov 2019 09:03:30 +0000 (14:33 +0530)
misc/quitcd/quitcd.bash
misc/quitcd/quitcd.csh
misc/quitcd/quitcd.fish
misc/quitcd/quitcd.zsh

index a26395dbec1311ed58e2567c301b531c0f936232..95939a009929cd60c4b9de74a4dabe4b55c233c4 100644 (file)
@@ -1,5 +1,11 @@
 n()
 {
+    # Block nesting of nnn in subshells
+    if [ $(expr $NNNLVL + 0) -ge 1 ]; then
+        echo "nnn is already running"
+        return
+    fi
+
     # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
     # To cd on quit only on ^G, export NNN_TMPFILE after the call to nnn
     export NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd
index 206e620a06e03c53164b756a9d90d98b1e590a95..ef95fff34ae65c02cce49b06622cc57883c7814d 100644 (file)
@@ -4,4 +4,4 @@
 # To cd on quit only on ^G, export NNN_TMPFILE after the call to nnn
 set NNN_TMPFILE=~/.config/nnn/.lastd
 
-alias n 'nnn; source "$NNN_TMPFILE"; rm "$NNN_TMPFILE"'
+alias n 'nnn; source "$NNN_TMPFILE"; rm -f "$NNN_TMPFILE"'
index 4117cc5148183ee92bc658e7b9feeeebbc974a63..12fccedb4617dd260a43dadd40a6087369ae79c1 100644 (file)
@@ -3,6 +3,12 @@
 # or, add the lines to the 'config.fish' file.
 
 function n --description 'support nnn quit and change directory'
+    # Block nesting of nnn in subshells
+    if [ (expr $NNNLVL + 0) -ge 1 ]
+        echo "nnn is already running"
+        return
+    end
+
     # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
     # To cd on quit only on ^G, export NNN_TMPFILE after the call to nnn
     if test -n "$XDG_CONFIG_HOME"
index 9259e4a69f92039e489f6e2cbecd54dc30b2281c..20a613f93a7c9aeaadf2c86a6ac4947a3cfd1b15 100644 (file)
@@ -1,5 +1,11 @@
 n()
 {
+    # Block nesting of nnn in subshells
+    if [ $(expr $NNNLVL + 0) -ge 1 ]; then
+        echo "nnn is already running"
+        return
+    fi
+
     # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
     # To cd on quit only on ^G, export NNN_TMPFILE after the call to nnn
     export NNN_TMPFILE=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd