mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Add Redir command to capture command output easily
This commit is contained in:
parent
37e9487076
commit
70d7f3aea5
@ -168,3 +168,12 @@ function! utils#GetGitBranch()
|
|||||||
return l:res
|
return l:res
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Redirect command output to a register for later processing.
|
||||||
|
" Ref: https://stackoverflow.com/q/2573021/6064933 and https://unix.stackexchange.com/q/8101/221410 .
|
||||||
|
function! utils#CaptureCommandOutput(command) abort
|
||||||
|
echomsg "command is" a:command
|
||||||
|
redir @m
|
||||||
|
execute a:command
|
||||||
|
redir END
|
||||||
|
endfunction
|
||||||
|
|||||||
2
plugin/command.vim
Normal file
2
plugin/command.vim
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
" Capture output from a command to register @m, to paste, press "mp
|
||||||
|
command! -nargs=1 -complete=command Redir call utils#CaptureCommandOutput(<q-args>)
|
||||||
Loading…
x
Reference in New Issue
Block a user