Hacker News new | ask | show | jobs
by barrkel 1859 days ago
How do people manage the platform differences between Linux, macOS, Windows WSL, Windows Cygwin, Solaris (at one point I had it on my NAS); and environment differences, such as work machines vs home machines?

I have my own dotfiles mechanism which splits out paths and configs by operating system, portable runtimes (e.g. Mono - may work on different OSes) and environments (enabling home and work configs to be stored in a separate repo and avoiding data leakage). Things like .bashrc and .bash_profile are assembled piecewise from fragments in each component.

Modifications to generated files by installers (notoriously, things like rvm, nvm etc. all want their stuff to be last in the config file, first in the path and all that) are detected so they can be integrated and not accidentally overwritten.

It's somewhat complex - I'm deliberately not linking it because I wouldn't recommend other people use mine, I have no time to support it - but to my mind these features are critical for any dotfile management system.

1 comments

I stole this from somewhere, but in bash at least you can do something like this:

if [ $(uname) = "Darwin" ]; then ... # macos

if [ "$TERM" != "cygwin" ] ; then ... # cygwin

I'm sure there are other ways to determine WSL and others you mentioned.

Oh there are selectors you can run, but what of you want different config files? Different inputrc or dircolors because you use different terminals, etc. And then there's the difficulty in managing an enormous do-everything script, vs something which is compiled for the platform.