.dotfiles
In Unix-like operating systems, any file or folder that starts with a dot character (for example, /home/user/.config), commonly called a dot file or dotfile, is to be treated as hidden. A convention arose of using dotfile in the user's home directory to store per-user configuration or informational text.
Here are the settings I use. There are installation scripts for most things, so getting them should be easy.
Feel free to adopt anything you like from these settings. However, I recommend you make your own, and only add things you understand and like, so you build your own toolchain.
Project Structure
Directory | Description |
---|---|
bin | executables |
config | zsh and bash configuration |
iterm2 | iterm2 configuration |
rc | all the dotfiles |
script | private helper scripts |
I put all personal and private configuration in config/personal.sh
, which is
ignored by git, so it doesn't accidentally end up on the internet.
Installation
Pre-requisites
Download and install the following applications manually:
Code
To install dotfiles:
git clone https://github.com/iain/dotfiles.git ~/.dotfiles
cd ~/.dotfiles
./script/install
This will backup any previous dotfiles you have.
Homebrew
To install all the neat little homebrew tools listed in Brewfile
:
brew tap Homebrew/bundle
brew bundle
iTerm
To configure iTerm:
- Open iTerm2.
- Go to the Preferences (
⌘,
) - In the General tab, check
Load preferences from a custom folder or URL
. - Fill in:
~/.dotfiles/iterm2
. - Restart iTerm2.
Git
To configure git, you need to tell Git who you are, and configure commit signing (highly recommended).
In this setup, make sure you use the same name and email as in GitHub.
To get git commit signing and verified commits in Github:
- Download and install GPG Suite from https://gpgtools.org/
- When launching you'll be asked to generate a new key pair. Do that.
- You'll be asked to upload the key. Optional, I think, but I did it.
- Right-Click on your newly generated key, choose "Copy". Your public key is now in your clipboard.
- On github, go to your settings: https://github.com/settings/gpg/new
- Click button "New GPG key"
- Paste your public key, you copied it in step 5.
- On the overview of your GPG keys on github, you'll see your "Key ID". Copy that to your clipboard.
Open ~/.gitconfig
and add the following, replacing values:
[credential]
helper = osxkeychain
[commit]
gpgsign = true
[user]
name = xxx
email = [email protected]
signingkey = XXXXXXXXXXXXXXXX
The signingkey
is the "Key ID" you copied in step 8.
Upon the next commit that you make, GPG suite will ask you for the password you entered in step 2.
asdf
I use asdf these days to install programming languages.
Here is how to install ruby (replace latest
with an older version if you like):
asdf plugin add ruby
asdf install ruby latest
asdf global ruby latest
Python and most other languages work the same, except NodeJS.
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
asdf install nodejs latest
asdf global nodejs latest
To update all plugins, when new versions come out:
asdf plugin update --all
Fonts
Get a couple of really good Terminal fonts with powerline support baked in:
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# cleanup
cd ..
rm -rf fonts/
Documentation
Below is extra documentation on what's configured in the dotfiles. Or at least, some of the highlights.
Vim
Vim is my editor of choice, I use it for all my coding needs.
All configuration is done in ~/.vimrc
and it will self-install automatically
the first time you start it. Delete (or move) your ~/.vim
directory to let it
(re)install.
To get new versions of your plugins after the first install:
:PlugUpgrade
:PlugUpdate
:PlugClean
The vim configuration should work on the terminal and macvim. I prefer the macvim version, mainly because font rendering is delegated to macOS, making it quite a bit faster.
The config works both in dark mode and light mode and switches based on your OS setting.
My personal preference is "Hack".
Aliases && Commands
There are a lot of aliases and commands in my dotfiles.
Configuration in ~/.dotfiles/config/general.sh
and bin files in ~/.dotfiles/bin
.
Command | Description |
---|---|
flushdns |
flush DNS cache (macOS only) |
imgcat |
show image in terminal (iTerm only) |
l |
alias of ls -FhAlo |
m |
opens file in existing macvim window |
psg |
find running process quickly |
ssh-copy-id |
copy your SSH key to remote server |
tf |
alias of tail -f -n 200 |
Other:
ls
is replaced by GNU version if gnu tools are installed on macOS.- Replaced
grep
withrg
aws-docker-login
for logging docker into AWS ECR.docker-stop-all
stops all running docker containersdocker-implode
deletes all docker image caches, run from time to time to get lots of disk space back
Git
I deprecated git checkout
in favor of git switch
and git restore
. git checkout
still works, just has a 30 second penalty.
Configuration for git is found in ~/.gitconfig
and ~/.dotfiles/config/git.sh
Here are some of the highlights:
Command | Description |
---|---|
aa |
short for git add --all && git status -s |
amend |
short for git commit --amend |
c |
short for git commit |
current |
show the SHA of the current commit |
d |
short for git diff |
dc |
short for git diff --cached |
g12 |
First 12 chars of current git commit |
gf |
short for git fetch --all && git status |
gpb |
Publish your branch without having to type branch name |
gpr |
Quickly make a draft PR in GitHub |
p |
short for git push |
re |
short for git restore |
s |
short for git status -s |
st |
short for git status |
sw |
short for git switch |
unstage |
short for git restore --cached -- |
up |
short for git pull --ff-only |
upstash |
short for git stash && up && git stash pop |
Other:
- Local changes will be rebased
- I regularly perform
git-cleanup
, which wraps the following tasks:git fetch --all --prune
- removes information about old remote branchesgit-delete-merged-branches
- removes branches that have been merged ingit-delete-squashed-branches
- removes branches that have been squashed in GitHubgit prune
- remove dangling objectsgit gc --aggressive --auto
- clean up files and optimize repository
- Only run the cleanup scripts from a clean default branch!
- All commands should be compatible with whatever default branch you have (see
git-default-branch
) - Default branch for new repos is
main
instead ofmaster
. - Read the
~/.gitconfig
file for more neat aliases.
Ruby
The configuration for ruby is found in ~/.dotfiles/config/ruby.sh
Here are some of the aliases:
Command | Description |
---|---|
b |
short for bundle install |
be |
short for bundle exec |
psr |
finds ruby processes |
r |
short for rails |
rdm |
will run migrations for development and test |
wip |
short for cucumber --profile wip |
Other:
- Rails, Rake, Cucumber, RSpec will use Spring automatically if it's available and binstubbed.
rspec_focus
andcucumber_focus
are for running a subset of tests and are setup to be used together with vim-test
Credits
Thanks everybody who puts their dotfiles online. I copied a bunch from practically every repository.
Feel free to use this or fork this. Additions are very welcome!