├── symlink_dot_zshrc ├── .gitignore ├── dot_config ├── git │ ├── attributes │ └── ignore └── starship.toml ├── dot_aliases ├── bundle.sh ├── nixos.sh └── git.sh ├── .chezmoiignore ├── .vscode └── settings.json ├── .chezmoi.toml.tmpl ├── run_onchange_before_install-packages-darwin.sh.tmpl ├── install.sh ├── run_onchange_before_install-packages-linux.sh.tmpl ├── dot_zshrc.user.tmpl ├── README.md ├── dot_gitconfig ├── dot_bin └── executable_git-backport └── AGENTS.md /symlink_dot_zshrc: -------------------------------------------------------------------------------- 1 | .zshrc.user 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dotfiles/bundle/cache/ 2 | dotfiles/bundle/plugin/ 3 | -------------------------------------------------------------------------------- /dot_config/git/attributes: -------------------------------------------------------------------------------- 1 | db/schema.rb merge=railsschema 2 | Gemfile.lock merge=bundlelock 3 | -------------------------------------------------------------------------------- /dot_aliases/bundle.sh: -------------------------------------------------------------------------------- 1 | alias b="bundle" 2 | alias bi="b install" 3 | alias bu="b update" 4 | alias be="b exec" 5 | -------------------------------------------------------------------------------- /dot_aliases/nixos.sh: -------------------------------------------------------------------------------- 1 | alias nixrebuild='sudo nixos-rebuild switch --flake ~/nixos-dotfiles' 2 | alias nixtest='sudo nixos-rebuild test --flake ~/nixos-dotfiles' 3 | alias nixupdate='nix flake update' 4 | -------------------------------------------------------------------------------- /.chezmoiignore: -------------------------------------------------------------------------------- 1 | install.sh 2 | README.md 3 | AGENTS.md 4 | .vscode/ 5 | 6 | {{- if .isNixOS }} 7 | .zshrc 8 | {{- end }} 9 | 10 | {{- if not .isNixOS }} 11 | .aliases/nixos.sh 12 | {{- end }} 13 | -------------------------------------------------------------------------------- /dot_config/git/ignore: -------------------------------------------------------------------------------- 1 | .DS\_Store 2 | .svn 3 | *.sqlite3 4 | *.swp 5 | *~ 6 | #*# 7 | vendor/ruby 8 | vendor/rbx 9 | .bundle 10 | doc/tags* 11 | .todo 12 | Session.vim 13 | *.orig 14 | .idea 15 | .rakeTasks 16 | .plans/ 17 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "chezmoiignore", 4 | "elgato", 5 | "Fira", 6 | "ghostty", 7 | "gpgconf", 8 | "hypr", 9 | "mdrp", 10 | "nixos", 11 | "wofi", 12 | "ykman" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.chezmoi.toml.tmpl: -------------------------------------------------------------------------------- 1 | {{- $isWorkComputer := false }} 2 | {{- $isNixOS := false }} 3 | {{- if eq (env "REMOTE_CONTAINERS") "true" }} 4 | sourceDir = "{{ .chezmoi.homeDir }}/dotfiles" 5 | {{- else }} 6 | {{- $isWorkComputer = promptBoolOnce . "isWorkComputer" "Is this a work computer" }} 7 | {{- end }} 8 | {{- if eq .chezmoi.os "linux" }} 9 | {{- if hasKey .chezmoi.osRelease "id" }} 10 | {{- $isNixOS = eq .chezmoi.osRelease.id "nixos" }} 11 | {{- end }} 12 | {{- end }} 13 | 14 | [data] 15 | isWorkComputer = {{ $isWorkComputer }} 16 | isNixOS = {{ $isNixOS }} 17 | -------------------------------------------------------------------------------- /run_onchange_before_install-packages-darwin.sh.tmpl: -------------------------------------------------------------------------------- 1 | {{- if eq .chezmoi.os "darwin" -}} 2 | #!/bin/bash 3 | 4 | brew bundle --file=- <&2 11 | if command -v curl >/dev/null; then 12 | chezmoi_install_script="$(curl -fsSL get.chezmoi.io)" 13 | elif command -v wget >/dev/null; then 14 | chezmoi_install_script="$(wget -qO- get.chezmoi.io)" 15 | else 16 | echo "To install chezmoi, you must have curl or wget installed." >&2 17 | exit 1 18 | fi 19 | sh -c "${chezmoi_install_script}" -- -b "${bin_dir}" 20 | unset chezmoi_install_script bin_dir 21 | fi 22 | 23 | # POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188 24 | script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)" 25 | 26 | set -- init --apply --source="${script_dir}" 27 | 28 | echo "Running 'chezmoi $*'" >&2 29 | # exec: replace current process with chezmoi 30 | exec "$chezmoi" "$@" 31 | -------------------------------------------------------------------------------- /run_onchange_before_install-packages-linux.sh.tmpl: -------------------------------------------------------------------------------- 1 | {{- if and (eq .chezmoi.os "linux") (not .isNixOS) -}} 2 | #!/bin/bash 3 | 4 | # Install Starship 5 | if ! command -v starship &> /dev/null; then 6 | echo "Installing Starship..." 7 | curl -sS https://starship.rs/install.sh | sh -s -- --yes 8 | fi 9 | 10 | # Install Fira Code Nerd Font 11 | FONT_DIR="$HOME/.local/share/fonts" 12 | FONT_NAME="FiraCode" 13 | 14 | if [ ! -f "$FONT_DIR/FiraCodeNerdFont-Regular.ttf" ]; then 15 | echo "Installing Fira Code Nerd Font..." 16 | mkdir -p "$FONT_DIR" 17 | 18 | # Download and extract the font 19 | FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FiraCode.zip" 20 | TEMP_ZIP=$(mktemp) 21 | 22 | curl -fLo "$TEMP_ZIP" "$FONT_URL" 23 | unzip -q "$TEMP_ZIP" -d "$FONT_DIR" '*.ttf' 24 | rm "$TEMP_ZIP" 25 | 26 | # Refresh font cache 27 | if command -v fc-cache &> /dev/null; then 28 | fc-cache -f "$FONT_DIR" 29 | fi 30 | 31 | echo "Fira Code Nerd Font installed successfully" 32 | fi 33 | {{ end -}} 34 | -------------------------------------------------------------------------------- /dot_aliases/git.sh: -------------------------------------------------------------------------------- 1 | alias eg="$EDITOR .git/config" 2 | alias g='git' 3 | alias ga='git a' 4 | alias gb='git b' 5 | alias gba='git ba' 6 | alias gc='git c' 7 | alias gca='git ca' 8 | alias gcam='git cam' 9 | alias gco='git co' 10 | alias gcp='git cp' 11 | alias gd='git d' 12 | alias gdc='git dc' 13 | alias gdm='git dm' 14 | alias gdw='git dw' 15 | alias gf="git f" 16 | alias gfix="git fix" 17 | alias gl='git l' 18 | alias gmf='git mf' 19 | alias gmt='git mt' 20 | alias gp='git p' 21 | alias gpl='git pl' 22 | alias gpr="git pull-resquest" 23 | alias gr='git r' 24 | alias grb='git rb' 25 | alias grba='git rba' 26 | alias grbc='git rbc' 27 | alias grbi='git rbi' 28 | alias grh='git rh' 29 | alias grmb='git rmb' 30 | alias gs='git s' 31 | alias gsa='git sa' 32 | alias gsp='git sp' 33 | alias gsq='git sq' 34 | alias gss='git ss' 35 | alias gun='git un' 36 | alias gup='git up' 37 | alias shopify='git config --local user.email rafael.franca@shopify.com && git config --local --unset user.name' 38 | alias me='git config --local user.email rafael@franca.dev && git config --local --unset user.name' 39 | alias rubyonrails='git config --local user.email rafael@rubyonrails.org && git config --local --unset user.name' 40 | -------------------------------------------------------------------------------- /dot_zshrc.user.tmpl: -------------------------------------------------------------------------------- 1 | # Key bindings 2 | bindkey -e 3 | bindkey '^p' history-search-backward 4 | bindkey '^n' history-search-forward 5 | 6 | # History 7 | export HISTFILE=~/.zsh_history 8 | export HISTSIZE=5000 9 | export SAVEHIST=$HISTSIZE 10 | export HISTDUP=erase 11 | export HISTTIMEFORMAT="[%F %T] " 12 | setopt append_history # append history to the history file 13 | setopt share_history # share command history data between all sessions 14 | setopt extended_history # record timestamp of command in HISTFILE 15 | setopt hist_ignore_all_dups # don't record duplicate commands 16 | setopt hist_save_no_dups # don't record duplicate commands 17 | setopt hist_ignore_dups # don't record duplicate commands 18 | setopt hist_find_no_dups # don't display duplicate commands 19 | setopt hist_ignore_space # ignore commands that start with space 20 | setopt hist_verify # show command with history expansion to user before running it 21 | 22 | export EDITOR='code --wait' 23 | 24 | # Aliases 25 | for i in ~/.aliases/*.sh ; do . $i ; done 26 | 27 | alias ls='ls --color' 28 | 29 | {{- if eq .chezmoi.os "darwin" }} 30 | # Mac-specific configurations 31 | export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) 32 | {{- end }} 33 | 34 | # Interactive prompt (Starship) 35 | if command -v starship &> /dev/null; then 36 | eval "$(starship init zsh)" 37 | else 38 | # Fallback to default prompt if starship is not installed 39 | autoload -Uz vcs_info 40 | precmd_functions+=( vcs_info ) 41 | setopt prompt_subst 42 | 43 | zstyle ':vcs_info:git:*' check-for-changes true 44 | zstyle ':vcs_info:*' unstagedstr '*' 45 | zstyle ':vcs_info:*' stagedstr '+' 46 | zstyle ':vcs_info:git:*' formats '%F{200}[%b%u%c]%f' 47 | zstyle ':vcs_info:*' enable git 48 | 49 | PROMPT='%(?.%F{green}√.%F{red}?%?)%f [$RUBY_ENGINE-$RUBY_VERSION] %B%~%b $vcs_info_msg_0_ $ ' 50 | fi 51 | 52 | # Completion 53 | autoload -Uz compinit && compinit 54 | 55 | zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' 56 | zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" 57 | 58 | # add .bin to the path 59 | export PATH=$PATH:~/.bin 60 | if [ -f ~/.local/bin/mise ]; then 61 | eval "$(~/.local/bin/mise activate zsh)" 62 | fi 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dotfiles 2 | 3 | My personal dotfiles managed with [chezmoi](https://www.chezmoi.io/). 4 | 5 | ## Quick Start 6 | 7 | ### Install on a new machine 8 | 9 | ```bash 10 | # Install chezmoi and apply dotfiles 11 | sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply rafaelfranca 12 | ``` 13 | 14 | ### Manual installation 15 | 16 | ```bash 17 | # Install chezmoi 18 | brew install chezmoi 19 | 20 | # Initialize and apply dotfiles 21 | chezmoi init rafaelfranca 22 | chezmoi apply 23 | ``` 24 | 25 | ## What's included 26 | 27 | - **Shell**: Zsh configuration with custom prompt and aliases 28 | - **Starship**: Cross-platform prompt with custom configuration 29 | - **Git**: Global configuration, ignore patterns, and attributes 30 | - **Homebrew**: Package management with brew bundle (macOS only) 31 | - **Linux**: Starship and font installation (non-NixOS systems) 32 | - **Scripts**: Custom executables in `~/.bin/` 33 | - **Aliases**: Organized shell aliases in `~/.aliases/` 34 | 35 | ## Daily usage 36 | 37 | ### Update dotfiles 38 | 39 | ```bash 40 | # Pull latest changes from repository 41 | chezmoi update 42 | ``` 43 | 44 | ### Edit dotfiles 45 | 46 | ```bash 47 | # Edit a file with your default editor 48 | chezmoi edit ~/.zshrc 49 | ``` 50 | 51 | ### Add new files 52 | 53 | ```bash 54 | # Add a file to be managed by chezmoi 55 | chezmoi add ~/.some-config-file 56 | 57 | # Add an executable script 58 | chezmoi add --template ~/.bin/my-script 59 | ``` 60 | 61 | ### Check what would change 62 | 63 | ```bash 64 | # See what chezmoi would do without applying 65 | chezmoi diff 66 | 67 | # Dry run 68 | chezmoi apply --dry-run --verbose 69 | ``` 70 | 71 | ## Platform-specific configuration 72 | 73 | Configuration automatically adapts based on the operating system: 74 | 75 | - **macOS**: Installs Homebrew packages and applies Mac-specific settings 76 | - **Linux**: Installs Starship and fonts (except on NixOS) 77 | - **NixOS**: Uses system zsh config 78 | 79 | ## Package management (macOS) 80 | 81 | Packages are managed via Homebrew and automatically installed/updated when the package list changes: 82 | 83 | ```bash 84 | # Edit the package list 85 | chezmoi edit ~/.local/share/chezmoi/run_onchange_before_install-packages-darwin.sh.tmpl 86 | 87 | # Apply changes (will run brew bundle automatically) 88 | chezmoi apply 89 | ``` 90 | 91 | ## Learn more 92 | 93 | - [Chezmoi documentation](https://www.chezmoi.io/) 94 | - [Quick start guide](https://www.chezmoi.io/quick-start/) 95 | - [User guide](https://www.chezmoi.io/user-guide/command-overview/) 96 | -------------------------------------------------------------------------------- /dot_gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | name = Rafael Mendonça França 3 | useConfigOnly = true 4 | [core] 5 | excludesfile = ~/.config/git/ignore 6 | attributesfile = ~/.config/git/attributes 7 | commitGraph = true 8 | [color] 9 | diff = auto 10 | status = auto 11 | branch = auto 12 | interactive = auto 13 | grep = always 14 | [alias] 15 | a = add 16 | b = branch 17 | ba = branch -a 18 | c = commit -v 19 | ca = commit -v -a 20 | cam = commit --amend 21 | co = checkout 22 | cp = cherry-pick 23 | d = diff 24 | dc = diff --cached 25 | dm = diff main 26 | dw = diff --word-diff=color 27 | f = fetch 28 | fix = commit --amend -C HEAD 29 | l = log --graph 30 | m = merge --no-edit 31 | mf = merge --ff-only 32 | mt = mergetool 33 | p = push 34 | pu = push -u 35 | pl = pull 36 | r = reset 37 | rb = rebase 38 | rba = rebase --abort 39 | rbc = rebase --continue 40 | rbi = rebase --ignore 41 | rh = reset --hard 42 | rmb = !sh -c 'git branch -d $1 && git push origin :$1' - 43 | s = status -s 44 | sa = stash apply 45 | sp = stash pop 46 | sq = rebase --interactive origin/main --autosquash 47 | ss = stash 48 | un = reset HEAD 49 | up = rebase origin/main 50 | recent = branch --sort=-committerdate --format=\"%(committerdate:relative)%09%(refname:short)\" 51 | branch-cleanup = ! git branch --merged | grep -v \"*\" | xargs git branch -d 52 | [push] 53 | default = current 54 | [merge] 55 | tool = code 56 | ff = false 57 | conflictstyle = merge 58 | [apply] 59 | whitespace = nowarn 60 | [format] 61 | pretty = %C(yellow)%h%Cblue%d%Creset %s %C(green) %an, %ar%Creset 62 | [branch] 63 | autosetuprebase = always 64 | [help] 65 | autocorrect = -1 66 | [log] 67 | date = local 68 | [grep] 69 | lineNumber = true 70 | [hub] 71 | protocol = git 72 | [mergetool] 73 | keepBackup = false 74 | keepTemporaries = false 75 | [pull] 76 | rebase = true 77 | [merge "bundlelock"] 78 | name = bundle lock 79 | driver = bundle lock 80 | [merge "railsschema"] 81 | name = newer Rails schema version 82 | driver = "ruby -e '\n\ 83 | system %(git), %(merge-file), %(--marker-size=%L), %(%A), %(%O), %(%B)\n\ 84 | b = File.read(%(%A))\n\ 85 | b.sub!(/^<+ .*\\nActiveRecord::Schema\\.define.:version => (\\d+). do\\n=+\\nActiveRecord::Schema\\.define.:version => (\\d+). do\\n>+ .*/) do\n\ 86 | %(ActiveRecord::Schema.define(:version => #{[$1, $2].max}) do)\n\ 87 | end\n\ 88 | File.open(%(%A), %(w)) {|f| f.write(b)}\n\ 89 | exit 1 if b.include?(%(<)*%L)'" 90 | [github] 91 | user = rafaelfranca 92 | [diff] 93 | algorithm = patience 94 | [protocol] 95 | version = 2 96 | [gc] 97 | writeCommitGraph = true 98 | [mergetool "code"] 99 | cmd = eval \"$EDITOR\" --merge $REMOTE $LOCAL $BASE $MERGED 100 | trustExitCode = true 101 | [commit] 102 | gpgsign = true 103 | [feature] 104 | manyFiles = true 105 | [advice] 106 | mergeConflict = false 107 | -------------------------------------------------------------------------------- /dot_bin/executable_git-backport: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script is to backport a commit from a branch to another branch. 4 | # It will checkout the target branch, cherry-pick the commit. 5 | # 6 | # If commit is a merge commit, use the -m option. 7 | # 8 | # Branch names matching X.Y pattern (e.g., 7.0, 7.1, 8.0) will be automatically 9 | # converted to X-Y-stable format (e.g., 7-0-stable, 7-1-stable, 8-0-stable). 10 | # Other branch names will be used as-is. 11 | # 12 | # Usage: 13 | # git-backport 14 | # git-backport -m 15 | # 16 | # Examples: 17 | # git-backport abc123 7.1 # Backports to 7-1-stable 18 | # git-backport -m def456 8.0 # Backports merge commit to 8-0-stable 19 | # git-backport abc123 main # Backports to main (no transformation) 20 | 21 | set -euo pipefail 22 | 23 | # Transform branch name: if it matches X.Y pattern, convert to X-Y-stable 24 | # Otherwise, use as-is 25 | transform_branch_name() { 26 | local branch="$1" 27 | # Check if branch matches pattern like 7.0, 7.1, 8.0, etc. 28 | if [[ "$branch" =~ ^[0-9]+\.[0-9]+$ ]]; then 29 | # Valid X.Y pattern - replace dots with hyphens and append -stable 30 | echo "${branch//\./-}-stable" 31 | else 32 | echo "$branch" 33 | fi 34 | } 35 | 36 | # Show usage information 37 | show_usage() { 38 | echo "Backport a commit from a branch to another branch." 39 | echo 40 | echo "Usage: git-backport [OPTIONS] " 41 | echo 42 | echo "Options:" 43 | echo " -m Specify that the commit is a merge commit" 44 | echo " --help Show this help message" 45 | echo 46 | echo "Note: Branch names matching X.Y pattern (e.g., 7.0, 7.1) will be" 47 | echo " automatically converted to X-Y-stable format (e.g., 7-0-stable)." 48 | echo 49 | echo "Examples:" 50 | echo " git-backport abc123 7.1 # Backports to 7-1-stable" 51 | echo " git-backport -m def456 8.0 # Backports merge commit to 8-0-stable" 52 | echo " git-backport abc123 main # Backports to main (no transformation)" 53 | } 54 | 55 | # Validate required arguments 56 | validate_arguments() { 57 | if [[ $# -ne 2 ]]; then 58 | echo "Error: Expected 2 arguments, got $#" >&2 59 | echo 60 | show_usage 61 | exit 1 62 | fi 63 | } 64 | 65 | # Main execution 66 | main() { 67 | # Parse options 68 | local is_merge=false 69 | 70 | while [[ $# -gt 0 ]]; do 71 | case "$1" in 72 | --help) 73 | show_usage 74 | exit 0 75 | ;; 76 | -m) 77 | is_merge=true 78 | shift 79 | ;; 80 | -*) 81 | echo "Error: Unknown option: $1" >&2 82 | echo 83 | show_usage 84 | exit 1 85 | ;; 86 | *) 87 | # Hit a non-option argument, stop parsing 88 | break 89 | ;; 90 | esac 91 | done 92 | 93 | # Validate we have the right number of arguments 94 | validate_arguments "$@" 95 | 96 | # Extract arguments 97 | local commit="$1" 98 | local target_branch 99 | target_branch=$(transform_branch_name "$2") 100 | 101 | # Perform backport 102 | echo "Checking out branch: $target_branch" 103 | git checkout "$target_branch" 104 | 105 | echo "Pulling latest changes..." 106 | git pull 107 | 108 | echo "Cherry-picking commit: $commit" 109 | if [[ "$is_merge" == true ]]; then 110 | git cherry-pick -m 1 "$commit" 111 | else 112 | git cherry-pick "$commit" 113 | fi 114 | 115 | echo "✓ Backport completed successfully!" 116 | } 117 | 118 | # Run main function with all arguments 119 | main "$@" 120 | -------------------------------------------------------------------------------- /dot_config/starship.toml: -------------------------------------------------------------------------------- 1 | format = """ 2 | $directory\ 3 | $git_branch\ 4 | $git_state\ 5 | $git_status\ 6 | $fill\ 7 | $ruby\ 8 | $nodejs\ 9 | $rust\ 10 | $cdm_duration\ 11 | $jobs\ 12 | $username 13 | $character 14 | """ 15 | 16 | # Use the color palette 17 | palette = "dracula" 18 | 19 | # Define Dracula color palette 20 | [palettes.dracula] 21 | background = "#282a36" 22 | current_line = "#44475a" 23 | foreground = "#f8f8f2" 24 | comment = "#6272a4" 25 | cyan = "#8be9fd" 26 | green = "#50fa7b" 27 | orange = "#ffb86c" 28 | pink = "#ff79c6" 29 | purple = "#bd93f9" 30 | red = "#ff5555" 31 | yellow = "#f1fa8c" 32 | 33 | [fill] 34 | symbol = " " 35 | 36 | [aws] 37 | symbol = " " 38 | 39 | [buf] 40 | symbol = " " 41 | 42 | [bun] 43 | symbol = " " 44 | 45 | [c] 46 | symbol = " " 47 | 48 | [cpp] 49 | symbol = " " 50 | 51 | [cmake] 52 | symbol = " " 53 | 54 | [conda] 55 | symbol = " " 56 | 57 | [crystal] 58 | symbol = " " 59 | 60 | [dart] 61 | symbol = " " 62 | 63 | [deno] 64 | symbol = " " 65 | 66 | [directory] 67 | read_only = " 󰌾" 68 | 69 | [docker_context] 70 | symbol = " " 71 | 72 | [elixir] 73 | symbol = " " 74 | 75 | [elm] 76 | symbol = " " 77 | 78 | [fennel] 79 | symbol = " " 80 | 81 | [fortran] 82 | symbol = " " 83 | 84 | [fossil_branch] 85 | symbol = " " 86 | 87 | [gcloud] 88 | symbol = " " 89 | 90 | [git_branch] 91 | symbol = " " 92 | 93 | [git_commit] 94 | tag_symbol = '  ' 95 | 96 | [golang] 97 | symbol = " " 98 | 99 | [gradle] 100 | symbol = " " 101 | 102 | [guix_shell] 103 | symbol = " " 104 | 105 | [haskell] 106 | symbol = " " 107 | 108 | [haxe] 109 | symbol = " " 110 | 111 | [hg_branch] 112 | symbol = " " 113 | 114 | [hostname] 115 | ssh_symbol = " " 116 | 117 | [java] 118 | symbol = " " 119 | 120 | [julia] 121 | symbol = " " 122 | 123 | [kotlin] 124 | symbol = " " 125 | 126 | [lua] 127 | symbol = " " 128 | 129 | [memory_usage] 130 | symbol = "󰍛 " 131 | 132 | [meson] 133 | symbol = "󰔷 " 134 | 135 | [nim] 136 | symbol = "󰆥 " 137 | 138 | [nix_shell] 139 | symbol = " " 140 | 141 | [nodejs] 142 | symbol = "󰎙 " 143 | 144 | [ocaml] 145 | symbol = " " 146 | 147 | [os.symbols] 148 | Alpaquita = " " 149 | Alpine = " " 150 | AlmaLinux = " " 151 | Amazon = " " 152 | Android = " " 153 | AOSC = " " 154 | Arch = " " 155 | Artix = " " 156 | CachyOS = " " 157 | CentOS = " " 158 | Debian = " " 159 | DragonFly = " " 160 | Emscripten = " " 161 | EndeavourOS = " " 162 | Fedora = " " 163 | FreeBSD = " " 164 | Garuda = "󰛓 " 165 | Gentoo = " " 166 | HardenedBSD = "󰞌 " 167 | Illumos = "󰈸 " 168 | Kali = " " 169 | Linux = " " 170 | Mabox = " " 171 | Macos = " " 172 | Manjaro = " " 173 | Mariner = " " 174 | MidnightBSD = " " 175 | Mint = " " 176 | NetBSD = " " 177 | NixOS = " " 178 | Nobara = " " 179 | OpenBSD = "󰈺 " 180 | openSUSE = " " 181 | OracleLinux = "󰌷 " 182 | Pop = " " 183 | Raspbian = " " 184 | Redhat = " " 185 | RedHatEnterprise = " " 186 | RockyLinux = " " 187 | Redox = "󰀘 " 188 | Solus = "󰠳 " 189 | SUSE = " " 190 | Ubuntu = " " 191 | Unknown = " " 192 | Void = " " 193 | Windows = "󰍲 " 194 | 195 | [package] 196 | symbol = "󰏗 " 197 | 198 | [perl] 199 | symbol = " " 200 | 201 | [php] 202 | symbol = " " 203 | 204 | [pijul_channel] 205 | symbol = " " 206 | 207 | [pixi] 208 | symbol = "󰏗 " 209 | 210 | [python] 211 | symbol = " " 212 | 213 | [rlang] 214 | symbol = "󰟔 " 215 | 216 | [ruby] 217 | symbol = " " 218 | 219 | [rust] 220 | symbol = "󱘗 " 221 | 222 | [scala] 223 | symbol = " " 224 | 225 | [status] 226 | symbol = " " 227 | 228 | [swift] 229 | symbol = " " 230 | 231 | [xmake] 232 | symbol = " " 233 | 234 | [zig] 235 | symbol = " " 236 | -------------------------------------------------------------------------------- /AGENTS.md: -------------------------------------------------------------------------------- 1 | # Agent Context for Dotfiles 2 | 3 | This document provides context for AI coding assistants working with these dotfiles. 4 | 5 | ## Overview 6 | 7 | These dotfiles are managed using [chezmoi](https://www.chezmoi.io/), a dotfile manager that uses a source-target model with templating support. 8 | 9 | ## Key Design Decisions 10 | 11 | ### Chezmoi Naming Conventions 12 | 13 | Files in `~/.local/share/chezmoi/` use special prefixes that determine how they're applied: 14 | 15 | - **`dot_`**: Creates hidden files (e.g., `dot_zshrc` → `~/.zshrc`) 16 | - **`executable_`**: Makes files executable (e.g., `executable_git-backport` → executable script) 17 | - **`.tmpl`**: Template files processed by chezmoi (e.g., `dot_zshrc.tmpl`) 18 | - **`run_onchange_`**: Scripts that run when their content changes 19 | - **`run_onchange_before_`**: Scripts that run before applying changes 20 | 21 | ### Directory Structure 22 | 23 | ``` 24 | ~/.local/share/chezmoi/ 25 | ├── .chezmoiignore # Platform-specific file exclusions 26 | ├── .chezmoi.toml.tmpl # Chezmoi configuration 27 | ├── dot_aliases/ # Shell aliases → ~/.aliases/ 28 | ├── dot_bin/ # Executable scripts → ~/.bin/ 29 | ├── dot_config/ # XDG config → ~/.config/ 30 | │ ├── git/ # Git ignore/attributes 31 | │ └── starship.toml # Starship prompt config 32 | ├── dot_gitconfig # Main git config → ~/.gitconfig 33 | ├── dot_zshrc.user.tmpl # User-specific zsh config 34 | ├── symlink_dot_zshrc # Zsh config symlink 35 | ├── run_onchange_before_install-packages-darwin.sh.tmpl # macOS packages 36 | └── run_onchange_before_install-packages-linux.sh.tmpl # Linux packages 37 | ``` 38 | 39 | ## Platform-Specific Configuration 40 | 41 | ### macOS-Specific Features 42 | 43 | 1. **Conditional templating**: Uses `{{- if eq .chezmoi.os "darwin" -}}` for macOS-only config 44 | 2. **Homebrew packages**: Managed via `run_onchange_before_install-packages-darwin.sh.tmpl` 45 | - Embeds Brewfile directly in script using bash here-document 46 | - Runs automatically when package list changes 47 | - Uses `brew bundle --no-lock --file=/dev/stdin` 48 | 49 | ### Linux-Specific Features 50 | 51 | 1. **Package installation**: Managed via `run_onchange_before_install-packages-linux.sh.tmpl` 52 | - Installs Starship prompt and Fira Code Nerd Font 53 | - Skipped on NixOS (uses declarative package management) 54 | 2. **NixOS support**: Special handling via `.chezmoiignore` 55 | - Uses system zsh config instead of dotfiles version 56 | 57 | ### Platform Detection 58 | 59 | Templates must safely check platform before accessing OS-specific variables: 60 | 61 | ```bash 62 | # Safe: Check OS before accessing osRelease 63 | {{- if and (eq .chezmoi.os "linux") (eq .chezmoi.osRelease.id "nixos") }} 64 | 65 | # Unsafe: osRelease doesn't exist on macOS 66 | {{- if eq .chezmoi.osRelease.id "nixos" }} 67 | ``` 68 | 69 | ### Templates in `.zshrc` 70 | 71 | The `.zshrc` file uses chezmoi templating to conditionally include Mac-specific configuration: 72 | 73 | ```bash 74 | {{- if eq .chezmoi.os "darwin" }} 75 | # Mac-specific configurations 76 | export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) 77 | {{- end }} 78 | ``` 79 | 80 | ## Shell Configuration (Zsh) 81 | 82 | - **Primary shell**: Zsh (no bash/readline configuration needed) 83 | - **Aliases**: Organized in `~/.aliases/*.sh` files, sourced in `.zshrc` 84 | - **Custom scripts**: Stored in `~/.bin/` (added to PATH) 85 | 86 | ## Git Configuration 87 | 88 | ### File Locations 89 | 90 | - **Primary config**: `~/.gitconfig` (takes precedence over XDG) 91 | - **Ignore patterns**: `~/.config/git/ignore` (XDG location) 92 | - **Attributes**: `~/.config/git/attributes` (XDG location) 93 | 94 | ### Why Not Full XDG for Git? 95 | 96 | `~/.gitconfig` is used instead of `~/.config/git/config` because: 97 | - Git reads `~/.gitconfig` AFTER `~/.config/git/config` (higher precedence) 98 | - Other tools may write to `~/.gitconfig`, and we want our config to win 99 | - More widely recognized and standard location 100 | 101 | Supporting files (ignore, attributes) use XDG for better organization. 102 | 103 | ## Common Operations 104 | 105 | ### Adding New Files 106 | 107 | ```bash 108 | # Regular file 109 | chezmoi add ~/.some-file 110 | 111 | # Executable script 112 | chezmoi add --template ~/.bin/script-name 113 | # Then rename in source: executable_script-name 114 | 115 | # Edit in source to add prefixes/suffixes as needed 116 | ``` 117 | 118 | ### Adding Packages (macOS) 119 | 120 | Edit `run_onchange_before_install-packages-darwin.sh.tmpl` and add to the here-document: 121 | 122 | ```bash 123 | brew "package-name" 124 | cask "application-name" 125 | mas "App Name", id: 123456 126 | ``` 127 | 128 | ### Testing Changes 129 | 130 | ```bash 131 | # See what would change 132 | chezmoi diff 133 | 134 | # Dry run with details 135 | chezmoi apply --dry-run --verbose 136 | ``` 137 | ## Troubleshooting 138 | 139 | ### Check what chezmoi sees 140 | 141 | ```bash 142 | # List managed files 143 | chezmoi managed 144 | 145 | # See target path for a source file 146 | chezmoi target-path ~/.local/share/chezmoi/dot_zshrc.tmpl 147 | 148 | # See source path for a target file 149 | chezmoi source-path ~/.zshrc 150 | ``` 151 | 152 | ### Verify templates 153 | 154 | ```bash 155 | # Execute template to see output 156 | chezmoi execute-template < ~/.local/share/chezmoi/dot_zshrc.tmpl 157 | ``` 158 | 159 | ## References 160 | 161 | - [Chezmoi documentation](https://www.chezmoi.io/) 162 | - [Source state attributes](https://www.chezmoi.io/reference/source-state-attributes/) 163 | - [macOS guide](https://www.chezmoi.io/user-guide/machines/macos/) 164 | - [Templating reference](https://www.chezmoi.io/reference/templates/) 165 | --------------------------------------------------------------------------------