summaryrefslogtreecommitdiffstats
path: root/.config/fish/functions/n.fish
diff options
context:
space:
mode:
authorYigit Sever2021-11-11 18:36:14 +0300
committerYigit Sever2021-11-11 18:36:14 +0300
commitbcd732aacc6a1bad700c8ceca5974656cbfc3cf2 (patch)
treedcd115b90a5b54a31d0eecdc2c03053484f0ed25 /.config/fish/functions/n.fish
parenta572a619da2464a234af7500f095c776c5c39df1 (diff)
downloaddotfiles-bcd732aacc6a1bad700c8ceca5974656cbfc3cf2.tar.gz
dotfiles-bcd732aacc6a1bad700c8ceca5974656cbfc3cf2.tar.bz2
dotfiles-bcd732aacc6a1bad700c8ceca5974656cbfc3cf2.zip
fish: welcome!
diffstat (limited to '.config/fish/functions/n.fish')
-rw-r--r--.config/fish/functions/n.fish33
1 files changed, 33 insertions, 0 deletions
diff --git a/.config/fish/functions/n.fish b/.config/fish/functions/n.fish
new file mode 100644
index 0000000..042011c
--- /dev/null
+++ b/.config/fish/functions/n.fish
@@ -0,0 +1,33 @@
1function n --wraps=nnn --description 'support nnn quit and change directory'
2 # Block nesting of nnn in subshells
3 if test -n "$NNNLVL"
4 if [ (expr $NNNLVL + 0) -ge 1 ]
5 echo "nnn is already running"
6 return
7 end
8 end
9
10 # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
11 # To cd on quit only on ^G, remove the "-x" as in:
12 # set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
13 # (or, to a custom path: set NNN_TMPFILE "/tmp/.lastd")
14 # or, export NNN_TMPFILE after nnn invocation
15 if test -n "$XDG_CONFIG_HOME"
16 set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
17 else
18 set NNN_TMPFILE "$HOME/.config/nnn/.lastd"
19 end
20
21 # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
22 # stty start undef
23 # stty stop undef
24 # stty lwrap undef
25 # stty lnext undef
26
27 nnn -c $argv
28
29 if test -e $NNN_TMPFILE
30 source $NNN_TMPFILE
31 rm $NNN_TMPFILE
32 end
33end