From 70d7f3aea5d8de71fc34a84b8b5b20c8bb01d077 Mon Sep 17 00:00:00 2001 From: jdhao Date: Fri, 13 Aug 2021 01:17:57 +0800 Subject: Add Redir command to capture command output easily --- autoload/utils.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'autoload/utils.vim') diff --git a/autoload/utils.vim b/autoload/utils.vim index 5bbc7e8..c573a48 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -168,3 +168,12 @@ function! utils#GetGitBranch() return l:res endif 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 -- cgit v1.2.3