Skip to content

Instantly share code, notes, and snippets.

@amstiel
Created May 20, 2018 09:22
Show Gist options
  • Save amstiel/910ed16b25d3e2a87bdf34ce402227cb to your computer and use it in GitHub Desktop.
Save amstiel/910ed16b25d3e2a87bdf34ce402227cb to your computer and use it in GitHub Desktop.
-- Cmder console '~' resolving'
-- Press ~<Tab> for resolving home dir
local function tilde_match (text, f, l)
if text == '~' then
clink.add_match(clink.get_env('home'))
clink.matches_are_files()
return true
end
if text:sub(1, 1) == '~' then
clink.add_match(string.gsub(text, "~", clink.get_env('home'), 1))
-- second match prevents adding a space so we can look for more matches
clink.add_match(string.gsub(text, "~", clink.get_env('home'), 1) .. '+')
clink.matches_are_files()
return true
end
end
clink.register_match_generator(tilde_match, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment