Created
May 26, 2012 03:21
-
-
Save somian/2791953 to your computer and use it in GitHub Desktop.
Get User "Desktop" well-known folder pathname in Vim (script)
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
let g:WinUserProfile = '' | |
try | |
let g:WinUserProfile = substitute(system('cygpath -am -C UTF8 -D'), '[[:cntrl:]]', '', 'g') | |
catch @^Vim\%((\a\+)\)\=:E\d\+@ " catch any error number | |
" Seeing E484: Can't open file /tmp/vWlY1IE/0 # for line 99 (is it because SHELL been messed w/?) | |
call confirm( | |
\ printf( | |
\ "%s: Could not system() to get WinUserProfile using cygpath under shell \"%s\": %s\n", | |
\ s:this_vimfile, &shell, v:exception), 'Ok', 'Ok', 'Warning') | |
endtry | |
if g:WinUserProfile != '' | |
let g:WinUserProfile = substitute(g:WinUserProfile, '\c/Desktop', '', '') | |
if !isdirectory(g:WinUserProfile) | |
call confirm( | |
\ printf('WARNING: dir for WinUserProfile does not exist: %s worked out "%s", | |
\ s:this_vimfile, g:WinUserProfile) ."\n", 'Ok', 'Ok', 'Warning') | |
finish | |
endi | |
else | |
call confirm('ERROR (critical): Cannot create WinUserProfile string', 'Ok', 'Ok', 'Warning') | |
endi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment