From 1a3bcb28a1c532b89ff014f9a2f580c0ba73f961 Mon Sep 17 00:00:00 2001 From: Abderrahmane TAHRI JOUTI <302837+atahrijouti@users.noreply.github.com> Date: Sun, 22 Oct 2023 20:43:03 +0200 Subject: [PATCH] Use `-print-last-dir` option for `lfcd.cmd` (#1444) * exit lf not the cmd * exit successfully * use -print-last-dir --- etc/lfcd.cmd | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/etc/lfcd.cmd b/etc/lfcd.cmd index 1d950981..ce23dd64 100644 --- a/etc/lfcd.cmd +++ b/etc/lfcd.cmd @@ -3,13 +3,4 @@ rem Change working dir in cmd.exe to last dir in lf on exit. rem rem You need to put this file to a folder in %PATH% variable. -:tmploop -set tmpfile="%tmp%\lf.%random%.tmp" -if exist %tmpfile% goto:tmploop -lf -last-dir-path=%tmpfile% %* -if not exist %tmpfile% exit -set /p dir=<%tmpfile% -del /f %tmpfile% -if not exist "%dir%" exit -if "%dir%" == "%cd%" exit -cd /d "%dir%" +for /f "usebackq tokens=*" %%d in (`lf -print-last-dir %*`) do cd %%d