Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple targets #11

Closed
wants to merge 1 commit into from
Closed

Conversation

nagromc
Copy link
Contributor

@nagromc nagromc commented Feb 5, 2015

Hi @anishathalye,

Please review this pull request allowing users to define targets.

If you have multiple hosts with different configurations, it is useful to execute a consistent group of tasks.

Allow the user to define multiple targets to execute a consistent group of tasks.
@anishathalye
Copy link
Owner

It's actually possible to achieve this effect in a variety of ways without adding additional complexity to Dotbot.

One way is the way I manage my dotfiles, with a common dotfiles repo and a dotfiles-local repo with branches for each machine (or category of config). I install both on every machine. I think this method works pretty well.

Another way to achieve an effect closer to what you have, with multiple targets that you can specify, is the following. You can have one file per target, $TARGET.conf.yaml, and then you can modify the install script to take targets on the command line and run all the corresponding installations. Here is an example install script:

#!/usr/bin/env bash

set -e

DEFAULT_CONFIG_PREFIX="default"
CONFIG_SUFFIX=".conf.yaml"
DOTBOT_DIR=".dotbot"

DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

cd "${BASEDIR}"
git submodule update --init --recursive "${DOTBOT_DIR}"

for conf in ${DEFAULT_CONFIG_PREFIX} ${@}; do
    "${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${conf}${CONFIG_SUFFIX}"
done

With this, for example, you can have a default.conf.yaml, and say, a mac.conf.yaml and work.conf.yaml. You can install by running

./install mac work

And it'll execute all three things.

Unless there are additional reasons to add this complexity to Dotbot itself, I'd prefer to avoid the additional complexity.

@dsifford
Copy link
Contributor

dsifford commented Feb 7, 2016

@anishathalye First: Thanks for your hard work on this... Came across dotbot yesterday and I'm already feeling the benefits

Anyway: I thought I'd mention that I found your above comment extremely helpful. I'd suggest perhaps adding that to the README file. @nagromc and I can't be the only ones interested in different workflows / machine.

Thanks again 🍻

@anishathalye
Copy link
Owner

Glad you're finding it useful!

Good point on adding it to the README. I'll re-open this issue, and I'll get to making the change as soon as I can.

@anishathalye
Copy link
Owner

Oh whoops nvm, this is a pull request, not an issue. See #72.

ProfeC added a commit to ProfeC/dotfiles that referenced this pull request Sep 27, 2016
Based on anishathalye/dotbot#11 (comment).

- Adds config for MacOS
- Renames install to default
- Updates editor config for yaml files.
@ProfeC
Copy link

ProfeC commented Sep 27, 2016

@anishathalye not 100% sure how my commit got to be in this pull request. I just added a link for reference in my commit. Please disregard.

Sorry!

... and THANKS!!! I'm really loving centralizing my config files with dotbot. Who knew!

@anishathalye
Copy link
Owner

Oh, no worries!

I'm glad to hear that you've found the tool to be useful! 😄

@borisrorsvort
Copy link

Dunno what’s wrong with the example above but I’ve not manage to make it work. I had to change it to:

configs=("$DEFAULT_CONFIG_PREFIX $@")

for CONFIG in $configs; do
  "${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIGS_DIR}${CONFIG}${CONFIG_SUFFIX}"
done

Can you verify if that makes sense @anishathalye ?

@anishathalye
Copy link
Owner

huh, not sure why the first one doesn't work for you…

@dsifford
Copy link
Contributor

The reason it doesn't work for @borisrorsvort might (emphasis might) be because the expansion isn't double-quoted in @anishathalye's example.

@borisrorsvort
Copy link

After some more investigation it’s not executing the next files if they were errors in the default one

@anishathalye
Copy link
Owner

Ah, okay... that's because of the set -e at the top of the script. See here for more info.

vagnerr added a commit to vagnerr/dotfiles that referenced this pull request Jul 20, 2017
hslatman added a commit to hslatman/dotfiles that referenced this pull request Aug 14, 2017
@angeliski angeliski mentioned this pull request Oct 10, 2017
andras-tim added a commit to andras-tim/dotfiles that referenced this pull request Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants