Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge branch 'master' of https://github.com/xolox/vim-misc
- Loading branch information
Showing
1 changed file
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
" Vim auto-load script | ||
" Author: Peter Odding <peter@peterodding.com> | ||
" Last Change: March 15, 2011 | ||
" Last Change: November 24, 2011 | ||
" URL: http://peterodding.com/code/vim/misc/ | ||
|
||
let g:xolox#misc#os#version = '0.1' | ||
|
||
" Check whether Vim is running on Microsoft Windows. | ||
|
||
function! xolox#misc#os#is_win() | ||
return has('win16') || has('win32') || has('win64') | ||
endfunction | ||
|
||
" Execute an external command (hiding the console on Windows when possible). | ||
|
||
function! xolox#misc#os#exec(cmdline, ...) | ||
try | ||
" Try using my shell.vim plug-in. | ||
return call('xolox#shell#execute', [a:cmdline, 1] + a:000) | ||
catch /^Vim\%((\a\+)\)\=:E117/ | ||
" Fall back to system() when we get an "unknown function" error. | ||
let output = call('system', [a:cmdline] + a:000) | ||
if v:shell_error | ||
throw printf("os.vim %s: Command %s failed: %s", g:xolox#misc#os#version, a:cmdline, xolox#misc#str#trim(output)) | ||
endif | ||
return split(output, "\n") | ||
endtry | ||
endfunction | ||
|
||
" vim: ts=2 sw=2 et |