Add function to print a command output to the buffer
This commit is contained in:
		@@ -67,8 +67,20 @@ Before (Define functions):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  " Write current file: helper to hide `set bt=`
 | 
					  " Write current file: helper to hide `set bt=`
 | 
				
			||||||
  function! WriteMe()
 | 
					  function! WriteMe()
 | 
				
			||||||
    set bt=
 | 
					    set buftype=
 | 
				
			||||||
    write %
 | 
					    write %
 | 
				
			||||||
  endfunction
 | 
					  endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  " print a command output to the buffer
 | 
				
			||||||
 | 
					  function! PrintCommand(cmd)
 | 
				
			||||||
 | 
					    redir => message
 | 
				
			||||||
 | 
					    silent execute a:cmd
 | 
				
			||||||
 | 
					    redir END
 | 
				
			||||||
 | 
					    if empty(message)
 | 
				
			||||||
 | 
					      Log 'no output'
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      silent put=message
 | 
				
			||||||
 | 
					    endif
 | 
				
			||||||
 | 
					  endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# vim: ft=vim
 | 
					# vim: ft=vim
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user