mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00:00
Merge pull request #1602 from mmai/patch-1
Create quitcd script for nushell
This commit is contained in:
commit
9656c809d2
18
misc/quitcd/quitcd.nu
Normal file
18
misc/quitcd/quitcd.nu
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
|
||||||
|
let cfgHome = ($env | default $env.HOME XDG_CONFIG_HOME | get XDG_CONFIG_HOME)
|
||||||
|
let-env NNN_TMPFILE = $"($cfgHome)/.config/nnn/.lastd"
|
||||||
|
|
||||||
|
def-env n [...x] {
|
||||||
|
# Launch nnn. Add desired flags after `^nnn`, ex: `^nnn -eda ($x | str join)`
|
||||||
|
^nnn ($x | str join)
|
||||||
|
let newpath = (
|
||||||
|
if ($env.NNN_TMPFILE | path exists) {
|
||||||
|
let newpath = (open $env.NNN_TMPFILE | parse 'cd "{nnnpath}"').0.nnnpath
|
||||||
|
^rm -f $env.NNN_TMPFILE
|
||||||
|
echo $newpath
|
||||||
|
} else {
|
||||||
|
pwd
|
||||||
|
}
|
||||||
|
)
|
||||||
|
cd $newpath
|
||||||
|
}
|
Loading…
Reference in a new issue