tadmccorkle / dotfiles

my dotfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dotfiles by tad

Dotfiles live on the cfg branch.

Dotfiles for my Windows and Ubuntu (WSL2) configurations. Requires PowerShell 7 or a Bash shell. PowerShell is assumed to be on Windows.

requirements

My current PowerShell configuration requires posh-git. It also requires the following line be added to one of the PowerShell profiles:

. $env:USERPROFILE\.config\powershell\profile.ps1

I also use Neovim, and my current configuration uses plugins that have other dependencies like CMake, clang/gcc, and 7z/gzip. The Neovim command :checkhealth can be used to get an idea of the dependencies that are needed; otherwise, take a look at plugin docs.

to use

Fork the repo. If any changes need to be made prior to applying the configuration, clone the repo, checkout the cfg branch, and make any necessary changes - probably a good idea to make sure aliases and path components will work on the target machine.

To apply the configuration:

  1. Define the following function/alias for the current shell scope.
# pwsh
function dotfiles { git --git-dir=$env:USERPROFILE/.dotfiles/ --work-tree=$env:USERPROFILE $args }
# bash
alias dotfiles="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"
  1. Clone into a bare repository pointing to the cfg branch in a .dotfiles directory of USERPROFILE/$HOME.
# pwsh
git clone -b cfg --bare <repo-url> $env:USERPROFILE/.dotfiles
# bash
git clone -b cfg --bare <repo-url> $HOME/.dotfiles
  1. Checkout the repo to your USERPROFILE/$HOME directory.
dotfiles checkout

Note

This won't overwrite any existing dotfiles also present in the repo. Either back up the existing files...

# pwsh
dotfiles checkout 2>&1 | Select-String -Pattern "\s+[._]" -Raw | %{ $_.Trim() } | %{
  mkdir .dotfiles.bak/$(Split-Path -Path $_ -Parent) -ErrorAction SilentlyContinue
  mv $_ .dotfiles.bak/$_ -ErrorAction SilentlyContinue
}
# bash
dotfiles checkout 2>&1 | grep -E "\s+[._]" | awk {'print $1'} | \
  xargs -I{} sh -c 'mkdir -p .dotfiles.bak/$(dirname {}) && mv {} .dotfiles.bak/{}'

...and run dotfiles checkout again or overwrite them with dotfiles checkout -f.

  1. Set the remote as upstream.
dotfiles push -u origin cfg
  1. Hide untracked files.
dotfiles config --local status.showUntrackedFiles no

Now manage the local git repo in your USERPROFILE/$HOME directory using dotfiles instead of git (i.e. dotfiles status, dotfiles add .bashrc, dotfiles add -u, dotfiles commit, etc.).

to apply with one command

You can automate the process by making a gist with all the commands shown above. My dotfiles configuration can be applied with my dotfiles-pwsh gist or dotfiles-bash gist by calling:

curl -Ls https://gist.githubusercontent.com/tadmccorkle/f57b24cdaf47ad4c999ab65c92db0244/raw | pwsh -NoProfile
# bash
curl -Ls https://gist.githubusercontent.com/tadmccorkle/93fc70287b30dd4e3985f8e8e41862a8/raw | /bin/bash

acknowledgements

About

my dotfiles

License:MIT License