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:
M Bakhtiyar Ali authored and GitHub committed 2024-02-04 18:38:12 +01:00
1 parent 2007ae51a1
commit 8bbcbdd0ea
1 file changed
+3 -12
+3 -12
View File
@@ -19,16 +19,7 @@
# }
# ]
def-env lfcd [] {
let tmp = (mktemp)
lf -last-dir-path $tmp
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)'
}
# For nushell version >= 0.87.0
def --env --wrapped lfcd [...args: string] {
cd (lf -print-last-dir $args)
}