anishathalye / dotbot

A tool that bootstraps your dotfiles ⚡️
MIT License
7.1k stars 295 forks source link

env if else #368

Open maxclax opened 1 week ago

maxclax commented 1 week ago
   ~/.config/nvim:
      path: ./config/nvim/lazyvim
      if: '[ "$NVIM_TYPE" = "lazyvim" ]'
    ~/.config/nvim:
      path: ./config/nvim/kickstart
      if: '[ "$NVIM_TYPE" = "kickstart" ]'

Can I use it? I have tried but any result. I have use also

    ~/.config/nvim:
      path: ./config/nvim/$NVIM_TYPE

But with it I have error like

Nonexistent source ~/.config/nvim -> config/nvim/lazyvim and with full path that also texted me about Nonexistent

anishathalye commented 2 days ago

The first version won't work (it's a YAML dict, and can't have duplicate keys, so one entry gets clobbered).

The second option should work. To test it, I tried adding the following to my install.conf.yaml file:

    ~/.config/nvim:
      path: ./config/nvim/$NVIM_TYPE

I also created the file, echo test > ./config/nvim/lazyvim, and then:

export NVIM_TYPE=lazyvim
./install

And I got the following output:

...
Creating link ~/.config/nvim -> /Users/anish/src/dotfiles/config/nvim/lazyvim
...

Could you say more about the error message you are seeing / paste it verbatim here?

maxclax commented 1 day ago

The first version won't work (it's a YAML dict, and can't have duplicate keys, so one entry gets clobbered).

The second option should work. To test it, I tried adding the following to my install.conf.yaml file:

    ~/.config/nvim:
      path: ./config/nvim/$NVIM_TYPE

I also created the file, echo test > ./config/nvim/lazyvim, and then:

export NVIM_TYPE=lazyvim
./install

And I got the following output:

...
Creating link ~/.config/nvim -> /Users/anish/src/dotfiles/config/nvim/lazyvim
...

Could you say more about the error message you are seeing / paste it verbatim here?

That interesting and logical to work but in my case I don't understand why I have this error because with VAR in path that like in installing process script looking not in correct direction and I have error Nonexistent source ~/.config/nvim -> config/nvim/lazyvim but when I tried use full path to my vim /Volume/dev/dotfiles/config/nvim/$NVIM_TYPE I have also same error but with full path but in same time I have correct path. Maybe some encoding for /

maxclax commented 1 day ago

And all work well when I use without VAR just /Volume/dev/dotfiles/config/nvim/lazyvim or ./config/nvim/lazyvim

anishathalye commented 1 day ago

That is perplexing. Could you share: OS version, Dotbot version, exact snippet of the config that you expect to work, and the verbatim error message you get? Could you also share info about your file system setup (are there any symlinks in the path to the file? Anything else unusual?), and any other information that might be helpful for debugging?