SMNDVC/dotfiles

★ 0Forks 0ShellGitHub ↗Compare

README

Dotfiles Management with GNU Stow

This repository uses GNU Stow to manage dotfiles by creating symlinks from your home directory to the files in this repository.

Structure

The dotfiles are organized into packages:

  • bash/ - Bash configuration files (.bashrc, .bashrc.bak, .inputrc)
  • git/ - Git configuration (.gitconfig)
  • ssh/ - SSH keys (.ssh/id_rsa, .ssh/id_rsa.pub)
  • openai/ - OpenAI configuration (.openai)

Installation on a New Machine

Prerequisites

  1. Install GNU Stow:

    # Arch Linux
    sudo pacman -S stow
    
    # Ubuntu/Debian
    sudo apt install stow
    
    # macOS
    brew install stow
    
    # Fedora
    sudo dnf install stow
  2. Verify installation:

    stow --version

Step-by-Step Installation

  1. Clone this repository (or copy it to your new machine):

    cd ~
    git clone <repository-url> dotfiles
    # Or if you're copying manually:
    # mkdir -p ~/dotfiles && cp -r <path-to-dotfiles>/* ~/dotfiles/
  2. Navigate to the dotfiles directory:

    cd ~/dotfiles
  3. Install all packages with stow:

    stow bash git ssh openai

    This will create symlinks in your home directory pointing to the files in this repository.

  4. Set proper permissions for SSH keys (important for security):

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/id_rsa
    chmod 644 ~/.ssh/id_rsa.pub
  5. Verify the installation:

    # Check that symlinks were created
    ls -la ~ | grep -E "\.bashrc|\.gitconfig|\.inputrc|\.openai"
    ls -la ~/.ssh | grep id_rsa
    
    # Verify symlinks point to the dotfiles directory
    readlink ~/.bashrc
    readlink ~/.gitconfig

Installing Individual Packages

If you only want to install specific packages:

cd ~/dotfiles

# Install only bash configs
stow bash

# Install only git config
stow git

# Install only SSH keys
stow ssh

# Install only OpenAI config
stow openai

Managing Dotfiles

Updating dotfiles

  1. Edit files directly in this repository:

    cd ~/dotfiles
    vim bash/.bashrc
    # or
    vim git/.gitconfig
  2. Changes are immediately reflected in your home directory (via symlinks)

  3. Commit and push changes:

    git add .
    git commit -m "Update dotfiles"
    git push

Removing packages

To uninstall a package (removes symlinks but keeps files in repo):

cd ~/dotfiles
stow -D bash    # Remove bash package
stow -D git     # Remove git package
stow -D ssh     # Remove SSH package
stow -D openai  # Remove OpenAI package

Reinstalling packages

If you need to reinstall all packages:

cd ~/dotfiles
stow -D bash git ssh openai  # Remove all
stow bash git ssh openai     # Reinstall all

Troubleshooting

Stow conflicts with existing files

If you have existing dotfiles that aren't symlinks, stow will refuse to overwrite them. You have a few options:

  1. Backup and remove existing files:

    mv ~/.bashrc ~/.bashrc.old
    stow bash
  2. Use stow's --adopt flag (moves existing files into the package):

    stow --adopt bash

Verify symlinks are working

# Check if files are symlinks
file ~/.bashrc
file ~/.gitconfig

# Should show: "symbolic link to ..."

Check what stow would do (dry run)

cd ~/dotfiles
stow -n bash    # Shows what would happen without making changes

Notes

  • SSH keys: Make sure to set proper permissions (600 for private key, 644 for public key)
  • Stow behavior: Stow creates symlinks from ~/dotfiles/package/ to ~/. The directory structure in each package mirrors your home directory structure.
  • Backup: Always backup existing dotfiles before installing, especially on a new machine where you might have default configurations you want to keep.

Quick Reference

# Install all
cd ~/dotfiles && stow bash git ssh openai

# Remove all
cd ~/dotfiles && stow -D bash git ssh openai

# Check what would happen (dry run)
cd ~/dotfiles && stow -n bash

# Reinstall a package
cd ~/dotfiles && stow -D bash && stow bash

Contributors

SMNDVC

Issues