dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

CtrlP Commands

Open christoomey opened this issue 9 years ago • 4 comments

Fuzzy selecting of commands. Optionally take a prefix, e.g. call CtrlpCommands('VTR')

Initial WIP implementation:

function! ExtractedCommandName(command_definition)
  let shell_split = "echo " . shellescape(a:command_definition) . " |  sed -E 's/.{4}//' | cut -d ' ' -f 1"
  return substitute(system(shell_split), "\n", "", "")
endfunction

" function! Mapped(fn, l)
"   let new_list = deepcopy(a:l)
"   call map(new_list, string(a:fn) . '(v:val)')
"   return new_list
" endfunction

function! s:GetCommandList()
  redir @a
  silent! command
  redir end
  let definitions = split(getreg("a"), "\n")
  let substitute_command = string(function('ExtractedCommandName')) . '(v:val)'
  let commands = map(definitions[1:10], substitute_command)
  echo commands
endfunction

command! Commands call <sid>GetCommandList()

christoomey avatar Oct 06 '15 18:10 christoomey

Whoa.

gabebw avatar Oct 06 '15 20:10 gabebw

Well, I mean, it doesn't "work" yet, so that's a pretty big caveat. But it'll get there.

christoomey avatar Oct 06 '15 20:10 christoomey

:Commands from fzf.vim does exactly this, right?

gabebw avatar Sep 18 '17 02:09 gabebw

No way that I can see to provide a filter on startup, but otherwise Commands is the functionality I'm describing.

christoomey avatar Sep 18 '17 02:09 christoomey