From 3a44bc809ddd963098ff96e60b376e6d581d7fe9 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 27 Sep 2019 18:17:24 -0400 Subject: [PATCH] add ~ match to vendor/clink.lua/ --- vendor/clink.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vendor/clink.lua b/vendor/clink.lua index d39a5ac..5e47246 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -385,7 +385,24 @@ local function svn_prompt_filter() return false end +local function tilde_match (text, f, l) + if text == '~' then + clink.add_match(clink.get_env('userprofile')) + clink.matches_are_files() + return true + end + + if text:sub(1, 1) == '~' then + clink.add_match(string.gsub(text, "~", clink.get_env('userprofile'), 1)) + -- second match prevents adding a space so we can look for more matches + clink.add_match(string.gsub(text, "~", clink.get_env('userprofile'), 1) .. '+') + clink.matches_are_files() + return true + end +end + -- insert the set_prompt at the very beginning so that it runs first +clink.register_match_generator(tilde_match, 1) clink.prompt.register_filter(set_prompt_filter, 1) clink.prompt.register_filter(hg_prompt_filter, 50) clink.prompt.register_filter(git_prompt_filter, 50)