# Flexdot [![Test](https://github.com/hidakatsuya/flexdot/workflows/Test/badge.svg?branch=master)](https://github.com/hidakatsuya/flexdot/actions?query=workflow%3ATest) A Flexible and Rake based dotfile manager. ## Getting Started ### Prerequisite Ruby 2.5+ ### Installing Install it as: $ gem install flexdot Then, create the following directory structure: ``` $HOME/ dotfiles/ ``` Create a `$HOME/dotfiles/Rakefile` with the following codes: ```ruby require 'flexdot' Flexdot.install_tasks( base_dir: '.', # $HOME/dotfiles/ target_dir: '/home/username' # $HOME/ ) ``` Finally, run `rake -T` in the `$HOME/dotfiles` and make sure that the output is as follows: $ rake -T rake clear_backups ## Example This example is my actual dotfile environment. I have two working environments, macOS and ubuntu. The dotfiles in these environments are slightly different, so each dotfile is separated. ### Directory Structure ``` $HOME/dotfiles ├── common │   ├── bin │   │   ├── git-delete-other-branches │   │   └── git-reset-and-clean │   ├── git │   │   └── ignore │   ├── rubygems │   │   └── .gemrc │   └── vim │   └── .vimrc ├── macOS │   ├── bash │   │   ├── .bash_profile │   │   └── .bashrc │   ├── git │   │   └── .gitconfig │   ├── karabiner │   │   └── tab-emulation.json │   └── vscode │   ├── keybindings.json │   └── settings.json ├── ubuntu │   ├── bash │   │   └── .bashrc │   ├── bin │   │   ├── upgrade-ghcli │   │   ├── utils │   │   ├── x-copy │   │   └── x-open │   ├── git │   │   └── .gitconfig │   ├── vscode │   │   ├── keybindings.json │   │   └── settings.json │   └── xkeysnail │   ├── config.py │   ├── debug.sh │   ├── restart.sh │   ├── start.sh │   └── stop.sh ├── macOS.yml ├── ubuntu.yml └── Rakefile ``` ### Available Commands When you run the `rake -T` command in that directory structure, you should have two installation commands available: $ rake -T rake clear_backups # Clear all backups rake install:macOS # Install dotfiles for macOS rake install:ubuntu # Install dotfiles for ubuntu ### Dotfile Index File `macOS.yml` and `ubuntu.yml` are for setting the link destination of dotfile. dotfile will be installed according to its setting. #### macOS.yml For example, `common -> bin -> git-delete-other-branchs` is `$HOME/dotfiles/common/bin/git-delete-other-branches`. And the value `bin` means `$HOME/bin` directory. So this defines linking `$HOME/dotfiles/common/bin/git-delete-other-branches` to `$HOME/bin/git-delete-other-branches`. ```yml common: bin: git-delete-other-branches: bin git-reset-and-clean: bin git: ignore: .config/git rubygems: .gemrc: . vim: .vimrc: . macOS: bash: .bash_profile: . .bashrc: . git: .gitconfig: . karabiner: tab-emulation.json: .config/karabiner/assets/complex_modifications vscode: keybindings.json: Library/Application Support/Code/User settings.json: Library/Application Support/Code/User ``` #### ubuntu.yml ```yml common: bin: git-delete-other-branchs: bin git-reset-and-clean: bin git: ignore: .config/git rubygems: .gemrc: . vim: .vimrc: . ubuntu: bash: .bashrc: . bin: upgrade-ghcli: bin utils: bin x-copy: bin x-open: bin git: .gitconfig: . vscode: keybindings.json: .config/Code/User settings.json: .config/Code/User xkeysnail: config.py: .xkeysnail debug.sh: .xkeysnail restart.sh: .xkeysnail start.sh: .xkeysnail stop.sh: .xkeysnail ``` ### Installing dotfiles $ rake install:macOS The following is the output result: ``` [already_linked] bin/git-delete-other-branches [already_linked] bin/git-reset-and-clean [already_linked] .config/git/ignore [already_linked] .gemrc [already_linked] .vimrc [link_created] .bash_profile (backup) [link_created] .bashrc (backup) [link_created] .gitconfig (backup) [link_created] .config/karabiner/assets/complex_modifications/tab-emulation.json (backup) [link_created] Library/Application Support/Code/User/keybindings.json (backup) [link_created] Library/Application Support/Code/User/settings.json (backup) ``` `already_linked` means skipped because `bin/git-delete-other-branches` is already linked. `link_created` means the link was created. Also, `(backup)` means that a file exists in the link path and that file was backed up to `$HOME/dotfiles/backup/YYYYMMDDHHIISS/filename`. ### Misc You can clear all backups in `$HOME/dotfiles/backup/YYYYMMDDHHIISS` to run `rake clear_backups`. $ rake clear_backups ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). ## Code of Conduct Everyone interacting in the Flexdot project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hidakatsuya/flexdot/blob/master/CODE_OF_CONDUCT.md).