Flexdot
A Flexible and Rake based dotfile manager.
Getting Started
Prerequisite
Ruby 2.5+
Installing
Create the following directory structure:
$HOME/
Create a Gemfile to install Flexdot:
$ cd $HOME/dotfiles
$ bundle init
Add this line to the Gemfile:
gem 'flexdot'
Or install it yourself as:
$ gem install flexdot
Then, create a $HOME/dotfiles/Rakefile with the following codes:
require 'flexdot'
Flexdot.setup(
home_dir: '/home/username',
# (optional)
# The dotfile directory path.
# Default '.'.
dotfiles_dir: '.',
# (optional)
# The `rake install` command will be available to install the dotfile for the specified index file.
# Default nil.
#
# Note that the `rake install` command is always available if you have a single index file.
default_index: 'name_of_an_index_file'
)
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
Rakefile
require 'flexdot'
Flexdot.setup(
home_dir: '..',
default_index: 'macOS'
)
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 # Install dotfiles for macOS
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.
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
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
Or
$ 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.
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.