Closed roachsinai closed 1 year ago
Dotdrop supports getting environment variable directly in variables
.
Try with something like this:
variables:
vim_home: "C:/Users/{{@@ env['USERNAME'] @@}}/vimfiles"
You can also enable logging (--verbose
) which will show you how the variables are interpreted, it's quite useful when using dynvariables
.
Thanks for remind me that wsl has Windows environment variables.
Does dotdrop using multithread? Check second line and last line in above image that vim_home
was evaluated before win_user
with below config:
dynvariables:
win_user: powershell.exe -command "[Environment]::UserName" | tr -d '\r\n'
vim_home: echo 'C:/Users/{{@@ win_user @@}}/vimfiles'
Again, I wouldn't use dynvariables
for what you're trying to do but go straight with variables
and using the ability to get environment variable in them directly.
Regarding your question, what you see is just a debug log of entries and is not related to the order in which the different variables were evaluated. The variables (variables
and dynvariables
) are internally transformed in a dictionary and then recursively evaluated until none is left. It seems from the above output that vim_home
failed to be evaluated. I guess if you scroll up a bit you should have some logs on the error that occured.
Still for a thing as simple as inserting username into a variable I wouldn't use a dynvariables
with some powershell oneliner, that's a bit overkill.
Yeah, I will use environment variable, too. By the way, didn't find keyword like failed
, error
.
Thanks for your reply!
I wanna know current windows user in wsl as dynvariable:
win_user
, then definevim_home
according to value ofwin_user
:when run dotdrop value of
vim_home
echo to beC:/Users/powershell.exe -command "[Environment]::UserName"
:If i comment definition of
vim_home
, then{{@@ win_user @@}}
will eval to the Windows username in lines the referwin_user
in dotfiles.So seems in block of yaml,
win_user
is just like a macro, so what happened in define ofvim_home
is just text substitution.Is there a way to get instant value of
win_user
in dynvariables block?Thanks!