From dff016528cdadcf15f8a246c5bd6730a4d549f07 Mon Sep 17 00:00:00 2001 From: Chris Antos Date: Wed, 17 May 2023 10:48:05 -0700 Subject: [PATCH 1/2] z.lua was missing some lines for z.cmd. The auto-init for z.cmd was missing a couple of lines. The HomeDir line, in particular, is important because it enables Lua to find the z.lua script. --- z.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/z.lua b/z.lua index 307644b..42b2abe 100755 --- a/z.lua +++ b/z.lua @@ -2703,6 +2703,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) From db1a863d40091675c1dbe4bf22795f9828433f0e Mon Sep 17 00:00:00 2001 From: Chris Antos Date: Wed, 17 May 2023 10:48:42 -0700 Subject: [PATCH 2/2] Update z completions for Clink. - Added description strings for the flags. - Added dir completions for the `-x` flag. --- z.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/z.lua b/z.lua index 42b2abe..7f75426 100755 --- a/z.lua +++ b/z.lua @@ -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