Skip to content

Commit

Permalink
Use -print-last-dir option for lfcd.cmd (#1444)
Browse files Browse the repository at this point in the history
* exit lf not the cmd

* exit successfully

* use -print-last-dir
  • Loading branch information
atahrijouti authored Oct 22, 2023
1 parent 154d718 commit 1a3bcb2
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions etc/lfcd.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1a3bcb2

Please sign in to comment.