Update lfcd.nu to support nushell >= 0.87.0 (#1575)
* Update lfcd.nu to support nushell >= 0.87.0 Deprecated def-env in favor of def --env https://www.nushell.sh/blog/2023-11-14-nushell_0_87_0.html#deprecated-commands-toc * Update lfcd.nu using `-print-last-dir` introduced in #1402
This commit is contained in:
1 parent
2007ae51a1
commit
8bbcbdd0ea
1 file changed
+3
-12
+3
-12
@@ -19,16 +19,7 @@
|
|||||||
# }
|
# }
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
def-env lfcd [] {
|
# For nushell version >= 0.87.0
|
||||||
let tmp = (mktemp)
|
def --env --wrapped lfcd [...args: string] {
|
||||||
lf -last-dir-path $tmp
|
cd (lf -print-last-dir $args)
|
||||||
try {
|
|
||||||
let target_dir = (open --raw $tmp)
|
|
||||||
rm -f $tmp
|
|
||||||
try {
|
|
||||||
if ($target_dir != $env.PWD) { cd $target_dir }
|
|
||||||
} catch { |e| print -e $'lfcd: Can not change to ($target_dir): ($e | get debug)' }
|
|
||||||
} catch {
|
|
||||||
|e| print -e $'lfcd: Reading ($tmp) returned an error: ($e | get debug)'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user