sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

quitcd.bash_zsh (845B)


      1 n ()
      2 {
      3     # Block nesting of nnn in subshells
      4     if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
      5         echo "nnn is already running"
      6         return
      7     fi
      8 
      9     # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
     10     # To cd on quit only on ^G, either remove the "export" as in:
     11     #    NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
     12     #    (or, to a custom path: NNN_TMPFILE=/tmp/.lastd)
     13     # or, export NNN_TMPFILE after nnn invocation
     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     nnn "$@"
     23 
     24     if [ -f "$NNN_TMPFILE" ]; then
     25             . "$NNN_TMPFILE"
     26             rm -f "$NNN_TMPFILE" > /dev/null
     27     fi
     28 }