Skip to content

Instantly share code, notes, and snippets.

@bstaint
Created April 3, 2017 06:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bstaint/54522f56ee807bf1a65a3c4cf717886e to your computer and use it in GitHub Desktop.
function s:FasdFunc(cmd, words)
let ret = ''
if a:cmd == 'e'
let ret = system('fasd -f ' . a:words)
elseif a:cmd == 'cd'
let ret = system('fasd -d ' . a:words)
endif
if len(ret) > 0
exec printf(':%s %s', a:cmd, ret)
endif
endfunction
function! FasdCompletion(ArgLead, CmdLine, CursorPos)
let ret = ''
let argList = split(a:CmdLine)
if len(argList) == 1
" This is the first argument so nothing special here
elseif len(argList) == 2 && a:CmdLine[-1:] != ' '
if argList[0] == 'E'
let ret = system('fasd -fl '. argList[1])
elseif argList[0] == 'C'
let ret = system('fasd -dl '. argList[1])
endif
return split(ret, '\n')
endif
endfunction
command! -nargs=1 -complete=customlist,FasdCompletion E call s:FasdFunc('e', <f-args>)
command! -nargs=1 -complete=customlist,FasdCompletion C call s:FasdFunc('cd', <f-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment