question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Platform specific link paths

See original GitHub issue

Hello, I’ve been using dotbot to manage my dotfiles for some time now. It has worked great thus far, since most applications read from a common configuration directory on all platforms. Sublime Text however, uses different directories depending on what platform you’re on.

Would it be feasible to add support for different destination paths depending on your OS? In Python there’s sys.platform which contains a string representing the platform Python is running on.

As for configuration syntax, I’m not sure. YAML has a construct where you can map keys to values, see example 2.6, but since dotbot maps links “the other way”, the syntax wouldn’t make sense (and is syntactically incorrect):

- link:
    {
     linux: ~/.config/sublime-text-3,
     darwin: ~/Library/Application Support/Sublime Text 3,
     win32: ~/Sublime Text 3
    }: Sublime Text 3/

If you flip the target and destination, I think it looks decent and you would still be able to configure links independently of the OS/platform. It would obviously break all existing configuration files, however.

- link:
    Sublime Text 3/:
      linux: ~/.config/sublime-text-3,
      darwin: ~/Library/Application Support/Sublime Text 3,
      win32: ~/Sublime Text 3
    vim/: ~/.vim

What do you think?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
robobenkleincommented, Mar 10, 2018

Apparently this can also be solved with the shell conditions feature (https://github.com/anishathalye/dotbot/issues/143):

For your example @sjthespian

- link:
  ~/.bashrc:
    path: bashrc
    if: '[ ! -f "/etc/debian_version" ]'
  ~/.bashrc:
    path: bashrc-debian
    if: '[ -f "/etc/debian_version" ]'
  ~/.hammerspoon:
    path: hammerspoon
    if: '[[ "$(uname)" == "Darwin" ]]'

Does that sound right?

3reactions
sjthespiancommented, Jun 29, 2016

I’ll throw in another vote for this feature with a slight twist. It would be nice to not only be able to have os-specific links, but also install config files for some applications only on the systems that support them, for example only installing my hammerspoon config if I’m on a Mac.

I think the config example above is along the lines of what I am thinking. If a platform isn’t listed, the link won’t be created on that platform and you would need a way to specify a default in some cases. for example:

- link:
  ~/.bashrc:
    platforms:
      - name: default
        path: bashrc     
      - name: debian
        path: bashrc-debian   
  ~/.hammerspoon:
    platforms:
      - name: darwin
        path: hammerspoon
Read more comments on GitHub >

github_iconTop Results From Across the Web

file - Platform independent paths in Java
The File class contains the following public members that you can use for platform specific file paths: static String pathSeparator :
Read more >
R: Platform Specific Variables
Used to separate paths in environment variables such as PATH and TEXINPUTS . character string, possibly "" . The name of an architecture-specific...
Read more >
Path (Java Platform SE 8 )
A Path represents a path that is hierarchical and composed of a sequence of directory and file name elements separated by a special...
Read more >
Path.Combine() isn't as cross-platform as you think it is
A StackOverflow question where the top-rated and accepted answer points out IWebHostEnvironment to get the root directory but not how to safely ...
Read more >
Path Customization — paths • renv - GitHub Pages
Note that renv will append platform-specific and version-specific entries to the set paths as appropriate. For example, if you have set:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found