Skip to content

Commit

Permalink
support tilde (~) tab completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Beej126 authored Sep 17, 2017
1 parent d565ad4 commit 60f50ca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions clink/lua/clink.lua
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,20 @@ function clink.filter_prompt(prompt)
end

-- vim: expandtab

-- from here: /~https://github.com/cmderdev/cmder/issues/1051#issuecomment-242201036
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
clink.register_match_generator(tilde_match, 1)

0 comments on commit 60f50ca

Please sign in to comment.