Convert Figma logo to code with AI

anishathalye logodotbot

A tool that bootstraps your dotfiles ⚡️

7,001
290
7,001
47

Top Related Projects

12,818

Manage your dotfiles across multiple diverse machines, securely.

3,121

rc file (dotfile) management

30,132

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS

📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.

Quick Overview

Dotbot is a tool that bootstraps your dotfiles (a collection of configuration files for your development environment) by creating symlinks from your home directory to your dotfiles repository. It provides a simple and flexible way to manage your dotfiles across multiple machines.

Pros

  • Simplicity: Dotbot has a straightforward and easy-to-use configuration format, making it simple to set up and maintain your dotfiles.
  • Flexibility: Dotbot allows you to customize the installation process, including the ability to run arbitrary shell commands during the installation.
  • Cross-platform: Dotbot works on various operating systems, including Linux, macOS, and Windows.
  • Extensibility: Dotbot can be extended with custom plugins, allowing you to integrate it with other tools and workflows.

Cons

  • Limited Functionality: Dotbot is primarily focused on managing symlinks and running shell commands, which may not be sufficient for more complex dotfile management needs.
  • Dependency on Git: Dotbot assumes that your dotfiles are stored in a Git repository, which may not be the case for all users.
  • Lack of Automatic Backups: Dotbot does not provide built-in functionality for automatically backing up your existing dotfiles before installing new ones.
  • Potential Conflicts: If you have existing dotfiles in your home directory, Dotbot may create conflicts or overwrite them during the installation process.

Getting Started

To get started with Dotbot, follow these steps:

  1. Create a Git repository for your dotfiles:
git init ~/dotfiles
  1. Add your configuration files (e.g., .bashrc, .vimrc, .gitconfig) to the ~/dotfiles directory.

  2. Install Dotbot by cloning the repository and running the installation script:

git clone https://github.com/anishathalye/dotbot ~/dotfiles/dotbot
cd ~/dotfiles
./dotbot/install
  1. Customize the install.conf.yaml file in your dotfiles repository to specify the files you want to symlink and any additional installation steps:
- link:
    ~/.bashrc: bashrc
    ~/.vimrc: vimrc
    ~/.gitconfig: gitconfig
- shell:
    - [git submodule update --init --recursive, Installing submodules]
  1. Run the installation again to apply the changes:
./dotbot/install

That's it! Dotbot will now create symlinks from your home directory to the corresponding files in your dotfiles repository.

Competitor Comparisons

12,818

Manage your dotfiles across multiple diverse machines, securely.

Pros of chezmoi

  • More feature-rich, supporting templates, encryption, and multiple machine configurations
  • Cross-platform compatibility (Windows, macOS, Linux)
  • Built-in version control system integration

Cons of chezmoi

  • Steeper learning curve due to more complex functionality
  • Requires installation of a separate tool, unlike Dotbot which is a simple Python script

Code comparison

chezmoi:

chezmoi init
chezmoi add ~/.bashrc
chezmoi apply

Dotbot:

- link:
    ~/.bashrc: bashrc
- shell:
    - [git submodule update --init --recursive, Installing submodules]

Summary

Chezmoi offers a more comprehensive dotfile management solution with advanced features like templating and encryption, making it suitable for complex setups across multiple machines. However, this comes at the cost of a steeper learning curve and the need to install a separate tool.

Dotbot, on the other hand, provides a simpler, more straightforward approach using a YAML configuration file and a Python script. It's easier to set up and use for basic dotfile management but lacks some of the advanced features found in chezmoi.

The choice between the two depends on the user's needs, with chezmoi being better for complex, multi-machine setups, and Dotbot for simpler, single-machine configurations.

3,121

rc file (dotfile) management

Pros of rcm

  • Written in shell script, making it more portable and easier to understand for users familiar with shell scripting
  • Supports multiple dotfile directories, allowing for better organization and separation of concerns
  • Includes a tagging system for managing different sets of dotfiles across various machines

Cons of rcm

  • Less flexible configuration options compared to Dotbot's YAML-based approach
  • Lacks built-in support for advanced features like command execution or templating
  • May require more manual setup and configuration for complex dotfile management scenarios

Code Comparison

rcm:

RCRC=$HOME/.dotfiles/rcrc rcup -v

Dotbot:

- link:
    ~/.bashrc: bashrc
    ~/.vimrc: vimrc

rcm uses a more command-line driven approach, while Dotbot relies on a configuration file for defining dotfile links and actions. Dotbot's YAML configuration provides a more declarative and potentially easier-to-read structure for managing dotfiles, especially for users less familiar with shell scripting.

Both tools aim to simplify dotfile management, but they cater to different user preferences and use cases. rcm offers a more traditional Unix-style approach, while Dotbot provides a more modern, configuration-driven solution.

30,132

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS

Pros of dotfiles

  • Comprehensive set of macOS defaults and configurations
  • Includes a wide range of tools and applications
  • Highly customizable and well-documented

Cons of dotfiles

  • Less flexible for managing dotfiles across multiple systems
  • Requires manual setup and installation of components
  • May include unnecessary configurations for some users

Code Comparison

dotfiles:

#!/usr/bin/env bash

# Install command-line tools using Homebrew
brew install git
brew install node
brew install python

Dotbot:

- shell:
    - [git submodule update --init --recursive, Installing submodules]
- link:
    ~/.gitconfig: gitconfig
    ~/.zshrc: zshrc

Key Differences

Dotbot focuses on providing a tool for managing dotfiles, while dotfiles is a collection of actual dotfiles and configurations. Dotbot offers a more structured approach to dotfile management, using YAML configuration files and supporting various operations like linking and shell command execution. dotfiles, on the other hand, provides a comprehensive set of pre-configured dotfiles and system settings, primarily tailored for macOS users.

Dotbot is more flexible and can be used across different systems, while dotfiles is more opinionated and macOS-centric. Users looking for a dotfile management tool might prefer Dotbot, while those seeking a ready-to-use configuration set for macOS might find dotfiles more suitable.

📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.

Pros of homebrew-bundle

  • Specifically designed for macOS package management
  • Integrates seamlessly with Homebrew ecosystem
  • Can manage casks, taps, and Mac App Store apps

Cons of homebrew-bundle

  • Limited to macOS environments
  • Focuses primarily on package management, not general dotfile management
  • Requires Homebrew to be installed

Code Comparison

dotbot:

- link:
    ~/.gitconfig: gitconfig
    ~/.zshrc: zshrc
- shell:
    - [git submodule update --init --recursive, Installing submodules]

homebrew-bundle:

tap "homebrew/cask"
brew "git"
cask "visual-studio-code"
mas "Xcode", id: 497799835

Summary

dotbot is a general-purpose dotfile management tool that works across platforms, allowing for symlink creation and shell command execution. It's more flexible but requires more setup.

homebrew-bundle is macOS-specific and focuses on package management through Homebrew. It's simpler to use for macOS users but less versatile for managing dotfiles directly.

Choose dotbot for cross-platform dotfile management with more customization options. Opt for homebrew-bundle if you're primarily managing macOS packages and apps through Homebrew.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Dotbot Build Status Coverage PyPI Python 3.6+

Dotbot makes installing your dotfiles as easy as git clone $url && cd dotfiles && ./install, even on a freshly installed system!


Rationale

Dotbot is a tool that bootstraps your dotfiles (it's a [Dot]files [bo]o[t]strapper, get it?). It does less than you think, because version control systems do more than you think.

Dotbot is designed to be lightweight and self-contained, with no external dependencies and no installation required. Dotbot can also be a drop-in replacement for any other tool you were using to manage your dotfiles, and Dotbot is VCS-agnostic -- it doesn't make any attempt to manage your dotfiles.

See this blog post or more resources on the tutorials page for more detailed explanations of how to organize your dotfiles.

Getting Started

Starting Fresh?

Great! You can automate the creation of your dotfiles by using the user-contributed init-dotfiles script. If you'd rather use a template repository, check out dotfiles_template. Or, if you're just looking for some inspiration, we've got you covered.

Integrate with Existing Dotfiles

The following will help you get set up using Dotbot in just a few steps.

If you're using Git, you can add Dotbot as a submodule:

cd ~/.dotfiles # replace with the path to your dotfiles
git init # initialize repository if needed
git submodule add https://github.com/anishathalye/dotbot
git config -f .gitmodules submodule.dotbot.ignore dirty # ignore dirty commits in the submodule
cp dotbot/tools/git-submodule/install .
touch install.conf.yaml

If you're using Mercurial, you can add Dotbot as a subrepo:

cd ~/.dotfiles # replace with the path to your dotfiles
hg init # initialize repository if needed
echo "dotbot = [git]https://github.com/anishathalye/dotbot" > .hgsub
hg add .hgsub
git clone https://github.com/anishathalye/dotbot
cp dotbot/tools/hg-subrepo/install .
touch install.conf.yaml

If you are using PowerShell instead of a POSIX shell, you can use the provided install.ps1 script instead of install. On Windows, Dotbot only supports Python 3.8+, and it requires that your account is allowed to create symbolic links.

To get started, you just need to fill in the install.conf.yaml and Dotbot will take care of the rest. To help you get started we have an example config file as well as configuration documentation for the accepted parameters.

Note: The install script is merely a shim that checks out the appropriate version of Dotbot and calls the full Dotbot installer. By default, the script assumes that the configuration is located in install.conf.yaml the Dotbot submodule is located in dotbot. You can change either of these parameters by editing the variables in the install script appropriately.

Setting up Dotbot as a submodule or subrepo locks it on the current version. You can upgrade Dotbot at any point. If using a submodule, run git submodule update --remote dotbot, substituting dotbot with the path to the Dotbot submodule; be sure to commit your changes before running ./install, otherwise the old version of Dotbot will be checked out by the install script. If using a subrepo, run git fetch && git checkout origin/master in the Dotbot directory.

If you prefer, you can install Dotbot from PyPI and call it as a command-line program:

pip install dotbot
touch install.conf.yaml

In this case, rather than running ./install, you can invoke Dotbot with dotbot -c <path to configuration file>.

Full Example

Here's an example of a complete configuration.

The conventional name for the configuration file is install.conf.yaml.

- defaults:
    link:
      relink: true

- clean: ['~']

- link:
    ~/.tmux.conf: tmux.conf
    ~/.vim: vim
    ~/.vimrc: vimrc

- create:
    - ~/downloads
    - ~/.vim/undo-history

- shell:
  - [git submodule update --init --recursive, Installing submodules]

The configuration file is typically written in YAML, but it can also be written in JSON (which is a subset of YAML). JSON configuration files are conventionally named install.conf.json.

Configuration

Dotbot uses YAML or JSON-formatted configuration files to let you specify how to set up your dotfiles. Currently, Dotbot knows how to link files and folders, create folders, execute shell commands, and clean directories of broken symbolic links. Dotbot also supports user plugins for custom commands.

Ideally, bootstrap configurations should be idempotent. That is, the installer should be able to be run multiple times without causing any problems. This makes a lot of things easier to do (in particular, syncing updates between machines becomes really easy).

Dotbot configuration files are arrays of tasks, where each task is a dictionary that contains a command name mapping to data for that command. Tasks are run in the order in which they are specified. Commands within a task do not have a defined ordering.

When writing nested constructs, keep in mind that YAML is whitespace-sensitive. Following the formatting used in the examples is a good idea. If a YAML configuration file is not behaving as you expect, try inspecting the equivalent JSON and check that it is correct.

Directives

Most Dotbot commands support both a simplified and extended syntax, and they can also be configured via setting defaults.

Link

Link commands specify how files and directories should be symbolically linked. If desired, items can be specified to be forcibly linked, overwriting existing files if necessary. Environment variables in paths are automatically expanded.

Format

Link commands are specified as a dictionary mapping targets to source locations. Source locations are specified relative to the base directory (that is specified when running the installer). If linking directories, do not include a trailing slash.

Link commands support an optional extended configuration. In this type of configuration, instead of specifying source locations directly, targets are mapped to extended configuration dictionaries.

ParameterExplanation
pathThe source for the symlink, the same as in the shortcut syntax (default: null, automatic (see below))
createWhen true, create parent directories to the link as needed. (default: false)
relinkRemoves the old target if it's a symlink (default: false)
forceForce removes the old target, file or folder, and forces a new link (default: false)
relativeUse a relative path to the source when creating the symlink (default: false, absolute links)
canonicalizeResolve any symbolic links encountered in the source to symlink to the canonical path (default: true, real paths)
ifExecute this in your $SHELL and only link if it is successful.
ignore-missingDo not fail if the source is missing and create the link anyway (default: false)
globTreat path as a glob pattern, expanding patterns referenced below, linking all files matched. (default: false)
excludeArray of glob patterns to remove from glob matches. Uses same syntax as path. Ignored if glob is false. (default: empty, keep all matches)
prefixPrepend prefix prefix to basename of each file when linked, when glob is true. (default: '')

When glob: True, Dotbot uses glob.glob to resolve glob paths, expanding Unix shell-style wildcards, which are not the same as regular expressions; Only the following are expanded:

PatternMeaning
*matches anything
**matches any file, recursively
?matches any single character
[seq]matches any character in seq
[!seq]matches any character not in seq

However, due to the design of glob.glob, using a glob pattern such as config/*, will not match items that begin with .. To specifically capture items that being with ., you will need to include the . in the pattern, like this: config/.*.

When using glob with the exclude: option, the paths in the exclude paths should be relative to the base directory, same as the glob pattern itself. For example, if a glob pattern vim/* matches directories vim/autoload, vim/ftdetect, vim/ftplugin, and vim/spell, and you want to ignore the spell directory, then you should use exclude: ["vim/spell"] (not just "spell").

Example

- link:
    ~/.config/terminator:
      create: true
      path: config/terminator
    ~/.vim: vim
    ~/.vimrc:
      relink: true
      path: vimrc
    ~/.zshrc:
      force: true
      path: zshrc
    ~/.hammerspoon:
      if: '[ `uname` = Darwin ]'
      path: hammerspoon
    ~/.config/:
      path: dotconf/config/**
    ~/:
      glob: true
      path: dotconf/*
      prefix: '.'

If the source location is omitted or set to null, Dotbot will use the basename of the destination, with a leading . stripped if present. This makes the following two config files equivalent.

Explicit sources:

- link:
    ~/bin/ack: ack
    ~/.vim: vim
    ~/.vimrc:
      relink: true
      path: vimrc
    ~/.zshrc:
      force: true
      path: zshrc
    ~/.config/:
      glob: true
      path: config/*
      relink: true
      exclude: [ config/Code ]
    ~/.config/Code/User/:
      create: true
      glob: true
      path: config/Code/User/*
      relink: true

Implicit sources:

- link:
    ~/bin/ack:
    ~/.vim:
    ~/.vimrc:
      relink: true
    ~/.zshrc:
      force: true
    ~/.config/:
      glob: true
      path: config/*
      relink: true
      exclude: [ config/Code ]
    ~/.config/Code/User/:
      create: true
      glob: true
      path: config/Code/User/*
      relink: true

Create

Create commands specify empty directories to be created. This can be useful for scaffolding out folders or parent folder structure required for various apps, plugins, shell commands, etc.

Format

Create commands are specified as an array of directories to be created. If you want to use the optional extended configuration, create commands are specified as dictionaries. For convenience, it's permissible to leave the options blank (null) in the dictionary syntax.

ParameterExplanation
modeThe file mode to use for creating the leaf directory (default: 0777)

The mode parameter is treated in the same way as in Python's os.mkdir. Its behavior is platform-dependent. On Unix systems, the current umask value is first masked out.

Example

- create:
    - ~/downloads
    - ~/.vim/undo-history
- create:
    ~/.ssh:
      mode: 0700
    ~/projects:

Shell

Shell commands specify shell commands to be run. Shell commands are run in the base directory (that is specified when running the installer).

Format

Shell commands can be specified in several different ways. The simplest way is just to specify a command as a string containing the command to be run.

Another way is to specify a two element array where the first element is the shell command and the second is an optional human-readable description.

Shell commands support an extended syntax as well, which provides more fine-grained control.

ParameterExplanation
commandThe command to be run
descriptionA human-readable message describing the command (default: null)
quietShow only the description but not the command in log output (default: false)
stdinAllow a command to read from standard input (default: false)
stdoutShow a command's output from stdout (default: false)
stderrShow a command's error output from stderr (default: false)

Note that quiet controls whether the command (a string) is printed in log output, it does not control whether the output from running the command is printed (that is controlled by stdout / stderr). When a command's stdin / stdout / stderr is not enabled (which is the default), it's connected to /dev/null, disabling input and hiding output.

Example

- shell:
  - chsh -s $(which zsh)
  - [chsh -s $(which zsh), Making zsh the default shell]
  -
    command: read var && echo Your variable is $var
    stdin: true
    stdout: true
    description: Reading and printing variable
    quiet: true
  -
    command: read fail
    stderr: true

Clean

Clean commands specify directories that should be checked for dead symbolic links. These dead links are removed automatically. Only dead links that point to somewhere within the dotfiles directory are removed unless the force option is set to true.

Format

Clean commands are specified as an array of directories to be cleaned.

Clean commands also support an extended configuration syntax.

ParameterExplanation
forceRemove dead links even if they don't point to a file inside the dotfiles directory (default: false)
recursiveTraverse the directory recursively looking for dead links (default: false)

Note: using the recursive option for ~ is not recommended because it will be slow.

Example

- clean: ['~']

- clean:
    ~/:
      force: true
    ~/.config:
      recursive: true

Defaults

Default options for plugins can be specified so that options don't have to be repeated many times. This can be very useful to use with the link command, for example.

Defaults apply to all commands that come after setting the defaults. Defaults can be set multiple times; each change replaces the defaults with a new set of options.

Format

Defaults are specified as a dictionary mapping action names to settings, which are dictionaries from option names to values.

Example

- defaults:
    link:
      create: true
      relink: true

Plugins

Dotbot also supports custom directives implemented by plugins. Plugins are implemented as subclasses of dotbot.Plugin, so they must implement can_handle() and handle(). The can_handle() method should return True if the plugin can handle an action with the given name. The handle() method should do something and return whether or not it completed successfully.

All built-in Dotbot directives are written as plugins that are loaded by default, so those can be used as a reference when writing custom plugins.

Plugins are loaded using the --plugin and --plugin-dir options, using either absolute paths or paths relative to the base directory. It is recommended that these options are added directly to the install script.

See here for a current list of plugins.

Command-line Arguments

Dotbot takes a number of command-line arguments; you can run Dotbot with --help, e.g. by running ./install --help, to see the full list of options. Here, we highlight a couple that are particularly interesting.

--only

You can call ./install --only [list of directives], such as ./install --only link, and Dotbot will only run those sections of the config file.

--except

You can call ./install --except [list of directives], such as ./install --except shell, and Dotbot will run all the sections of the config file except the ones listed.

Wiki

Check out the Dotbot wiki for more information, tips and tricks, user-contributed plugins, and more.

Contributing

Do you have a feature request, bug report, or patch? Great! See CONTRIBUTING.md for information on what you can do about that.

License

Copyright (c) Anish Athalye. Released under the MIT License. See LICENSE.md for details.