Skip to content

Commit

Permalink
Update lfcd.nu to support nushell >= 0.87.0 (#1575)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ZennoZenith authored Feb 4, 2024
1 parent 2007ae5 commit 8bbcbdd
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions etc/lfcd.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 8bbcbdd

Please sign in to comment.