@@ -2101,10 +2101,28 @@ function z_clink_init()
21012101 end
21022102 return {}
21032103 end
2104+ local dirmatchfunc = function (word )
2105+ clink .matches_are_files (1 )
2106+ return clink .match_files (word .. ' *' , true , clink .find_dirs )
2107+ end
2108+ local dirmatchparser = clink .arg .new_parser ():set_arguments ({ dirmatchfunc })
21042109 local z_parser = clink .arg .new_parser ()
21052110 z_parser :set_arguments ({ z_match_completion })
2106- z_parser :set_flags (" -c" , " -r" , " -i" , " --cd" , " -e" , " -b" , " --add" , " -x" , " --purge" ,
2107- " --init" , " -l" , " -s" , " --complete" , " --help" , " -h" )
2111+ z_parser :set_flags (" -r" , " -i" , " -I" , " -t" , " -l" , " -c" , " -e" , " -b" , " -x" .. dirmatchparser , " -h" )
2112+ if z_parser .adddescriptions then
2113+ z_parser :adddescriptions ({
2114+ [' -r' ] = " cd to highest ranked dir matching" ,
2115+ [' -i' ] = " cd with interactive selection" ,
2116+ [' -I' ] = " cd with interactive selection using fzf" ,
2117+ [' -t' ] = " cd to most recently accessed dir matching" ,
2118+ [' -l' ] = " list matches instead of cd" ,
2119+ [' -c' ] = " restrict matches to subdirs of cwd (or %PWD% if set)" ,
2120+ [' -e' ] = " echo the best match, don't cd" ,
2121+ [' -b' ] = " jump backwards to given dir or to project root" ,
2122+ [' -x' ] = { " dir" , " remove path from history" },
2123+ [' -h' ] = " show help" ,
2124+ })
2125+ end
21082126 clink .arg .register_parser (" z" , z_parser )
21092127end
21102128
@@ -2703,6 +2721,8 @@ function z_windows_init(opts)
27032721 else
27042722 print (' @echo off' )
27052723 print (' setlocal EnableDelayedExpansion' )
2724+ print (' set "HomeDir=%~dp0"' ) -- So that Lua can find the z.lua file.
2725+ print (' set "PathSave=%PATH%"' )
27062726 print (' set "LuaExe=' .. os .interpreter () .. ' "' )
27072727 print (' set "LuaScript=' .. os .scriptname () .. ' "' )
27082728 print (script_init_cmd )
0 commit comments