dotfiles
Personal shell, git, and editor configuration, machine provisioning scripts, small
command-line utilities, and a collection of reference notes for macOS and Linux
(Linux Mint / Ubuntu / Raspberry Pi OS).
Heads up: these files are tuned for one person (Jorge Yau). shell/.gitconfig
contains a real name and email, and several scripts assume particular branch names
or registries. Read Before you install and
Caveats before copying anything over your own config.
Table of Contents
Quick start
git clone git@github.com:codenameyau/dotfiles.git ~/Workspace/dotfiles
Back up what you already have, then copy the dotfiles into $HOME:
mkdir -p ~/dotfiles-backup && cp -v ~/.bashrc ~/.bash_profile ~/.zshrc ~/.gitconfig ~/.gitignore_global ~/.bash_aliases ~/dotfiles-backup/ 2>/dev/null
Open a new terminal (or source the changed file) to pick up the changes.
To make the scripts in bin/ runnable from anywhere, add the directory to your
PATH in ~/.zshrc or ~/.bash_profile / ~/.bashrc:
export PATH="$HOME/Workspace/dotfiles/bin:$PATH"
For a brand-new Mac, see Machine provisioning instead.
Before you install
- The install scripts copy, they don't symlink.
setup.sh and update.sh run
cp -v, overwriting files in $HOME without a backup. Edits you make in ~ are
not reflected in the repo; edits in the repo need to be re-copied.
- Run them from the repo root. Both scripts use relative paths (
shell/.bashrc,
git-hooks/..., .git/hooks/...).
- Bash files are only copied if they already exist.
~/.bashrc is overwritten only
if a ~/.bashrc already exists, and likewise for ~/.bash_profile and ~/.zshrc.
This is how the scripts tell macOS (which uses .bash_profile/.zshrc) from Linux
(which uses .bashrc).
- Change the git identity.
shell/.gitconfig sets user.name/user.email and the
changes, contributions, and flow aliases filter on --author="codenameyau".
- HTTPS GitHub URLs are rewritten to SSH.
.gitconfig has
url."git@github.com:".insteadOf = https://github.com/, so every git clone https://github.com/... goes over SSH. You need an SSH key registered with GitHub
(docs), or
remove that block.
.zshrc is built around oh-my-zsh. It loads ~/.oh-my-zsh if installed, then
~/.ohmyzshrc, ~/.zshrc_extras, and ~/.zshrc.local if they exist. Each of these is
optional, so the file also works in a plain zsh, just without the theme and plugins.
Repository layout
dotfiles/
├── setup.sh # First-time install: copy dotfiles + install post-commit hook
├── update.sh # Re-copy dotfiles (bash, zsh, git) into $HOME
├── shell/ # Dotfiles destined for $HOME
│ ├── .bash_profile # macOS bash login shell
│ ├── .bashrc # Linux bash interactive shell
│ ├── .bash_aliases # Git shortcuts and helper functions (bash)
│ ├── .bash_extras # Empty placeholder for machine-local bash config
│ ├── .zshrc # Zsh + oh-my-zsh config, history, aliases
│ ├── .zshrc_extras # kubectl context in RPROMPT (zsh-kubectl-prompt)
│ ├── .ohmyzshrc # Custom prompt: virtualenv, exit status, git branch
│ ├── .gitconfig # Git identity, aliases, colors, push/URL behavior
│ ├── .gitignore_global # Global ignore list (node_modules, .DS_Store, ...)
│ ├── .inputrc # GNU Readline key bindings
│ ├── .ackrc # ack search defaults
│ └── .config/fusuma/ # Linux touchpad gesture config
├── bin/ # Standalone CLI utilities (add to PATH)
├── git-hooks/ # Reusable git hooks: <hook-name>--<purpose>
├── scripts/
│ ├── exercises/ # Bash practice scripts
│ ├── open-source/ # Vendored third-party scripts
│ └── workflow/ # Release/deploy automation
├── provision/ # New-machine setup
│ ├── README.md # Manual setup checklist (apps, Python, Ruby)
│ ├── osx/setup.sh # Homebrew, oh-my-zsh, fzf, node, vim
│ ├── osx/config.sh # macOS `defaults write` tweaks
│ ├── linux-mint/setup.sh # apt packages, git-lfs, node, Brave, fusuma
│ └── iterm2-profile.json # iTerm2 profile (colors, keys)
├── vim/ # .vimrc (Vundle) + install notes
├── vscode/ # VS Code user settings, launch.json, extension list
├── sublime/ # Sublime Text preferences
├── docs/ # Reference notes (bash, git, networking, servers, Pi)
└── reference/bash-sheet.md # Annotated copy of Greg's Wiki BashSheet
How installation works
setup.sh
setup.sh is meant to be run once, from the repo root, on a machine that
already has this repo cloned:
chmod u+x git-hooks/*.
- Installs
git-hooks/post-commit--dotfiles as this
repo's own .git/hooks/post-commit, so committing a change to a dotfile re-copies it
into $HOME (see Git hooks).
- Copies
.bash_aliases, .gitconfig, and .gitignore_global into $HOME.
- Copies
.bashrc if ~/.bashrc exists and .bash_profile if ~/.bash_profile exists.
It does not copy the zsh files, .bash_extras, .inputrc, .ackrc, or the vim
config.
update.sh
update.sh re-copies dotfiles after you pull or edit them:
Source in shell/ |
Copied to ~/ when |
.bash_aliases |
always |
.gitconfig |
always |
.gitignore_global |
always |
.bashrc, .bash_extras |
~/.bashrc exists |
.bash_profile, .bash_extras |
~/.bash_profile exists |
.zshrc, .zshrc_extras |
~/.zshrc exists |
If you have a customized ~/.bash_extras or ~/.zshrc_extras, update.sh will
overwrite it with the repo version (an empty file and the kubectl prompt,
respectively). Keep machine-local secrets and tweaks in ~/.zshrc.local, which
.zshrc sources last and nothing in this repo overwrites.
Installing a single file
Every file is plain text, so you can grab one without cloning:
curl -fsSL -o ~/.gitignore_global https://raw.githubusercontent.com/codenameyau/dotfiles/master/shell/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
The vim config is installed the same way; see vim/README.md.
Keeping configs in sync
The copy-based approach is simple but drifts: change ~/.zshrc directly and the repo
never learns about it. To see what has drifted:
for f in .bashrc .bash_profile .bash_aliases .zshrc .zshrc_extras .gitconfig .gitignore_global; do [ -f ~/$f ] && ! cmp -s shell/$f ~/$f && echo "differs: $f"; done
diff -u shell/.zshrc ~/.zshrc
If you'd rather edit in one place, replace the copies with symlinks (run from the repo
root):
ln -sfv "$PWD/shell/.zshrc" ~/.zshrc
Symlinks, GNU Stow, bare git repos, and chezmoi are compared in
docs/dotfiles.md.
Shell configuration
Which file gets loaded when
Which startup file runs depends on the shell and on whether it is a login and/or
interactive shell. This is the single most common source of "my alias doesn't work"
confusion.
| Shell |
Login (macOS Terminal/iTerm2 tab, ssh, bash -l) |
Interactive non-login (new tab in most Linux terminals, typing bash) |
Non-interactive (scripts) |
| bash |
/etc/profile, then the first of ~/.bash_profile, ~/.bash_login, ~/.profile |
~/.bashrc (Debian/Ubuntu also read /etc/bash.bashrc) |
$BASH_ENV, if set |
| zsh |
~/.zshenv → ~/.zprofile → ~/.zshrc → ~/.zlogin |
~/.zshenv → ~/.zshrc |
~/.zshenv |
Consequences for this repo:
- macOS has defaulted to zsh since Catalina (10.15). On a Mac,
~/.zshrc is what
matters; .bash_profile is only used if you switch back with chsh -s /bin/bash.
- macOS terminals start login shells, which is why the macOS bash file is
.bash_profile. Linux terminal emulators usually start non-login shells, so the
Linux file is .bashrc.
- A common pattern is to have
.bash_profile just source .bashrc so both cases
behave the same:
[ -f ~/.bashrc ] && . ~/.bashrc
- Reload after editing with
source ~/.zshrc (or the sp alias in bash), or
exec zsh for a clean restart of the shell.
More detail, including $ZDOTDIR and the XDG directories, is in
docs/dotfiles.md.
Bash: .bash_profile (macOS) and .bashrc (Linux)
shell/.bash_profile (macOS):
- Appends
/opt/cabal/bin (Haskell) to PATH.
- History:
HISTCONTROL=ignoreboth (skip duplicates and lines starting with a space),
HISTIGNORE='cd*:rm*' (never record cd/rm commands), 100 lines in memory and 200
on disk.
- Colors:
CLICOLOR=1 and a BSD LSCOLORS palette.
less syntax highlighting through src-hilite-lesspipe.sh from Homebrew's
source-highlight package, with LESS=' -R -X -F ' (pass colors through, don't clear
the screen, quit if the output fits on one screen).
- Homebrew's
bash-completion.
- Sources, if present:
~/.bash_prompt (from
shiny-prompt), ~/.bash_aliases,
~/.bash_extras.
shell/.bashrc (Linux) starts from the Ubuntu default and adds: