quitcd.bash_sh_zsh (990B)
1 n () 2 { 3 # Block nesting of nnn in subshells 4 [ "${NNNLVL:-0}" -eq 0 ] || { 5 echo "nnn is already running" 6 return 7 } 8 9 # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) 10 # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to 11 # see. To cd on quit only on ^G, remove the "export" and make sure not to 12 # use a custom path, i.e. set NNN_TMPFILE *exactly* as follows: 13 # NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" 14 export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" 15 16 # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn 17 # stty start undef 18 # stty stop undef 19 # stty lwrap undef 20 # stty lnext undef 21 22 # The command builtin allows one to alias nnn to n, if desired, without 23 # making an infinitely recursive alias 24 command nnn "$@" 25 26 [ ! -f "$NNN_TMPFILE" ] || { 27 . "$NNN_TMPFILE" 28 rm -f "$NNN_TMPFILE" > /dev/null 29 } 30 }