Skip to content

Instantly share code, notes, and snippets.

@EloB
Last active July 4, 2024 00:28
Show Gist options
  • Save EloB/6ab7dc2a08072efbd859bf9a098b9a63 to your computer and use it in GitHub Desktop.
Save EloB/6ab7dc2a08072efbd859bf9a098b9a63 to your computer and use it in GitHub Desktop.
Installation instructions for my Dotfiles

Dotfiles

Instructions for the dotfile repository on https://github.com/EloB/dotfiles.

Introduction

The dotfiles in this repository are installed using a bare Git repository. This method does not use symlinks (like most other dotfile repositories).

After the installation, all the dotfiles will be physically present in your home folder, yet, you will still have them under full version control.

Installation

curl -Ls https://bit.ly/install-dotfiles-now | bash

The URL https://bit.ly/install-dotfiles-now is simply a shortened link to the dotfiles-install.sh file in this Gist, and the above command downloads this file and executes it in a sub-shell.

In particular, the dotfiles-install.sh file does the following:

  • Clone the dotfile repository to a bare Git repository into ~/.dotfiles
  • Move your existing dotfiles to ~/.dotfiles.backup
  • Check out all the dotfiles (and dot-directories) to your home directory

If you don't need your old dotfiles anymore, you can safely delete the created ~/.dotfiles.backup directory.

And Now?

Now all the dotfiles from the repository are installed in your home directory. However, as mentioned, you still have them under full version control via the bare Git repository in ~/.dotfiles.

To interact with the bare Git repository, you need the following alias:

alias dotfiles='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

With the dotfiles alias, you can now manage the dotfiles via the bare Git repository, just as you would with the git command:

Edited your dotfiles? No problem, commit and push the changes:

dotfiles add ~/.vimrc
dotfiles commit -m "Edit .vimrc"
dotfiles push

Pushed changes to the remote repository from another machine? Easy, just pull down the new version:

dotfiles pull

Want to know what's going on? Sure:

dotfiles status

Submodules

The dotfile repository supports submodules (Git repositories within another Git repository).

The case for submodules occurs typically with Vim plugins, if you install them with pathogen.vim by cloning the respective Git repository into a directory under ~/.vim/bundle.

Here are some common tasks when using submodules:

  • Add a Vim plugin as a submodule to the repository:

    dotfiles submodule add https://github.com/tpope/vim-surround .vim/bundle/vim-surround
    dotfiles commit
    dotfiles push
    # Download files of submodule on local machine
    dotfiles submodule init
  • Pull changes that inlude a newly added submodule on another machine:

    dotfiles pull
    dotfiles submodule init
    dotfiles submodule update
  • List all submodules in the repository (including the commit that is used for each submodule):

    dotfiles submodule status
  • Update the submodules in the repository to the newest commits:

    dotfiles submodule update --remote
    dotfiles add <changed_files>
    dotfiles commit

References

The used installation method using a bare Git repository is described here:

# Installation script (Bash) for https://github.com/EloB/dotfiles
set -e
#------------------------------------------------------------------------------#
# Download
#------------------------------------------------------------------------------#
echo "> Downloading dotfiles..."
dir=.dotfiles
git clone --quiet --bare git@github.com:EloB/dotfiles.git "$HOME/$dir"
cmd() { git --git-dir="$HOME/$dir" --work-tree="$HOME" "$@"; }
#------------------------------------------------------------------------------#
# Backup already existing dotfiles
#------------------------------------------------------------------------------#
files=($(cmd ls-tree -r HEAD | awk '{print $NF}'))
bkp=.dotfiles.backup
for f in "${files[@]}"; do
# File at root ==> back up file
if [[ $(basename "$f") = "$f" ]]; then
[[ -f "$HOME/$f" ]] && mkdir -p "$HOME/$bkp" && mv "$HOME/$f" "$HOME/$bkp" && echo "> Backing up: $f ==> $bkp/$f"
# File in nested directory ==> back up outermost directory
else
d=${f%%/*}
if [[ -d "$HOME/$d" ]]; then
[[ -d "$HOME/$bkp/$d" ]] && rm -rf "$HOME/$bkp/$d"
mkdir -p "$HOME/$bkp" && mv "$HOME/$d" "$HOME/$bkp" && echo "> Backing up: $d/ ==> $bkp/$d/"
fi
fi
done
#------------------------------------------------------------------------------#
# Install
#------------------------------------------------------------------------------#
cmd checkout
cmd submodule --quiet init
cmd submodule --quiet update
cmd config status.showUntrackedFiles no
echo "> Success! The following dotfiles have been installed to $HOME:"
printf ' %s\n' "${files[@]}"
@EloB
Copy link
Author

EloB commented Jan 31, 2023

@EloB
Copy link
Author

EloB commented Jan 31, 2023

ZSH options
man zshoptions

@EloB
Copy link
Author

EloB commented Feb 1, 2023

To make Java work do:
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

If it doesn't work look info:
brew info java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment