Created
May 17, 2011 10:04
-
-
Save kyohsuke/976232 to your computer and use it in GitHub Desktop.
環境変数を波及させるのって、こんな感じだったらいいのかな?
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
function! s:pushEnv(shname) | |
if a:shname == 'bash' | |
let l:envs = split(system('bash -c "source ~/.bashrc; source ~/.bash_profile; export"')) | |
elseif a:shname == 'zsh' | |
let l:envs = split(system('zsh -c "source ~/.zshrc; source ~/.zshenv; export"')) | |
else | |
return | |
endif | |
for l:env in l:envs | |
unlet! l:envkeyval | |
unlet! l:envkey | |
unlet! l:envval | |
let l:envkeyval = split(l:env, '=') | |
let l:envkey = l:envkeyval[0] | |
unlet l:envkeyval[0] | |
let l:envval = join(l:envkeyval, '=') | |
execute 'let $' . l:envkey . '="' . l:envval . '"' | |
endfor | |
endfunction | |
call s:pushEnv('zsh') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
おぉ、アドバイスありがとうございます!!
こっちの gist はブログに貼るために利用しちゃって書き換えられないので、
vimrc の方で vimproc#system を利用する形に変更します!