sistema_progs

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

quitcd.nu (572B)


      1 # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
      2 let cfgHome = ($env | default $"($env.HOME)/.config" XDG_CONFIG_HOME | get XDG_CONFIG_HOME)
      3 let-env NNN_TMPFILE = $"($cfgHome)/nnn/.lastd"
      4 
      5 def-env n [...x] {
      6   # Launch nnn. Add desired flags after `^nnn`, ex: `^nnn -eda ($x | str join)`
      7   ^nnn ($x | str join)
      8   let newpath = (
      9     if ($env.NNN_TMPFILE | path exists) {
     10       let newpath = (open $env.NNN_TMPFILE | parse 'cd "{nnnpath}"').0.nnnpath
     11       ^rm -f $env.NNN_TMPFILE
     12       echo $newpath
     13     } else {
     14       pwd
     15     }
     16   )
     17   cd $newpath
     18 }