Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions z.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2101,10 +2101,28 @@ function z_clink_init()
end
return {}
end
local dirmatchfunc = function (word)
clink.matches_are_files(1)
return clink.match_files(word..'*', true, clink.find_dirs)
end
local dirmatchparser = clink.arg.new_parser():set_arguments({ dirmatchfunc })
local z_parser = clink.arg.new_parser()
z_parser:set_arguments({ z_match_completion })
z_parser:set_flags("-c", "-r", "-i", "--cd", "-e", "-b", "--add", "-x", "--purge",
"--init", "-l", "-s", "--complete", "--help", "-h")
z_parser:set_flags("-r", "-i", "-I", "-t", "-l", "-c", "-e", "-b", "-x"..dirmatchparser, "-h")
if z_parser.adddescriptions then
z_parser:adddescriptions({
['-r'] = "cd to highest ranked dir matching",
['-i'] = "cd with interactive selection",
['-I'] = "cd with interactive selection using fzf",
['-t'] = "cd to most recently accessed dir matching",
['-l'] = "list matches instead of cd",
['-c'] = "restrict matches to subdirs of cwd (or %PWD% if set)",
['-e'] = "echo the best match, don't cd",
['-b'] = "jump backwards to given dir or to project root",
['-x'] = { " dir", "remove path from history" },
['-h'] = "show help",
})
end
clink.arg.register_parser("z", z_parser)
end

Expand Down Expand Up @@ -2703,6 +2721,8 @@ function z_windows_init(opts)
else
print('@echo off')
print('setlocal EnableDelayedExpansion')
print('set "HomeDir=%~dp0"') -- So that Lua can find the z.lua file.
print('set "PathSave=%PATH%"')
print('set "LuaExe=' .. os.interpreter() .. '"')
print('set "LuaScript=' .. os.scriptname() .. '"')
print(script_init_cmd)
Expand Down