sistema_progs

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

quitcd.fish (1186B)


      1 # Rename this file to match the name of the function
      2 # e.g. ~/.config/fish/functions/n.fish
      3 # or, add the lines to the 'config.fish' file.
      4 
      5 function n --wraps nnn --description 'support nnn quit and change directory'
      6     # Block nesting of nnn in subshells
      7     if test -n "$NNNLVL" -a "$NNNLVL" -ge 1
      8         echo "nnn is already running"
      9         return
     10     end
     11 
     12     # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
     13     # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to
     14     # see. To cd on quit only on ^G, remove the "-x" from both lines below,
     15     # without changing the paths.
     16     if test -n "$XDG_CONFIG_HOME"
     17         set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
     18     else
     19         set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
     20     end
     21 
     22     # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
     23     # stty start undef
     24     # stty stop undef
     25     # stty lwrap undef
     26     # stty lnext undef
     27 
     28     # The command function allows one to alias this function to `nnn` without
     29     # making an infinitely recursive alias
     30     command nnn $argv
     31 
     32     if test -e $NNN_TMPFILE
     33         source $NNN_TMPFILE
     34         rm $NNN_TMPFILE
     35     end
     36 end