Skip to main content

Manage and edit $HOME dotfiles using Python + git = <3

Project description

mydot -- A Python module for managing dotfiles

Super-charged version of the Atlassian approach to managing dotfiles using a bare git repo + fzf magic! Quickly edit files, add changes, run scripts, grep through dotfiles, or discard work-tree changes with ease.

Quick Start

  1. Install dependencies:

    sudo apt install fzf git    # Ubuntu/Debian
    brew install fzf git        # MacOS/Homebrew
    
  2. Configure shell: At the bottom of your ~/.bashrc or ~/.zshhrc add:

    export DOTFILES="$HOME/.config/dotfiles"
    alias config='/usr/bin/git --git-dir=$DOTFILES --work-tree=$HOME'
    

    what and why?:

    • DOTFILES: variable pointing to your local --bare dotfiles repository
    • config: git alias to directly address the --bare dotfiles repository
  3. Initialize dotfiles repository:

    # reload shell configu
    source ~/.bashrc            # if using bash
    source ~/.zshrcc            # if using zsh
    
    mkdir -pv $DOTFILES         # create directory
    git init --bare $DOTFILES   # initialize --bare git repository
    
  4. Install mydot and disable viewing of untracked files

    pip install --user mydot    # if using pip
    pipx install mydot          # if using pipx
    mydot git config --local status.showUntrackedFiles no
    
  5. Add files to your dotfiles repo

    mydot git add ~/.vimrc ~/.tmux.conf ~/.bashrc ~/.bash_aliases ~/.zshrc
    mydot git commit -m "the journey of a thousand miles begins with one step"
    

    protip: You can use all your regular git commands, including aliases, when calling mydot git

  6. Feel the power with mydot (and the pre-installed alias d.)

    d. -e           # modify tracked files in your $EDITOR (tab in fzf for multiselect)
    d. -a           # choose which modified files to stage for commit
    d. git commit   # commit changes
    
    d. -g "EDITOR"  # find all files with lines containing the string EDITOR
                    # works with regex too! e.g, EDITOR$ something.*var ^$
    
    d. -r           # run any executable script in your dotfiles repo
    d. -s           # see the state of your repo
    d. -l           # list all files under version control
    
    d. --export     # make a tarball of your dotfiles + bare git repo
    d. --clip       # put file paths into the clipboard
    
    d. --restore    # remove files from staging area
    d. --discard    # discard unstaged changes from work tree
    
    d.              # see the help message detailing available commands
    

Going Deeper

Useful aliases

alias es="mydot --edit"     # quick select a file to edit
alias rs="mydot --run"      # quick select a script to run

If you ever run into an issue where the mydot CLI is reading flags meant for mydot git you can fallback to the config alias from step 1 which acts as a special git command that only applies for the dotfiles repo.

For example mydot git rm -r ~/.tmux would see the -r flag and try to run an executable in your dotfiles. Instead use config rm -r ~/.tmux and the files in the directory will be removed recursively.

Source of Truth

This project is available on GitHub and GitLab. Each push to master automatically goes to both so choose whichever platform you prefer. All releases are published to PyPi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mydot-0.7.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

mydot-0.7.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file mydot-0.7.1.tar.gz.

File metadata

  • Download URL: mydot-0.7.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for mydot-0.7.1.tar.gz
Algorithm Hash digest
SHA256 2faed5988fcf19fa6010c3c339616f7196544f94222c638213695a9aec78d8df
MD5 36186ae7bbad3c21ad7b37fc5fa80b9b
BLAKE2b-256 421e74d28d0d0eaaf8e7297a5e12f26dda17fe9228a23b7f7aab1a4eefddb77e

See more details on using hashes here.

File details

Details for the file mydot-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: mydot-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for mydot-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c9be59da3dfc6c3b1179aea4e4b6578dfe05a488e7270edcda1da725f61d8c2
MD5 bdfd8a7e90fd3f7f81154aa4f4761e3f
BLAKE2b-256 c4c1e4b16b53a470963a88480259de2fdfc00cc80d52400d17fdbb9d7f1cb7f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page