From f96891b6ec7eb693bc19fe524631779af98746cd Mon Sep 17 00:00:00 2001 From: Sarthak Jain Date: Sat, 18 Jul 2026 14:38:41 +0530 Subject: [PATCH] refactor: consolidate all branches into single-branch Strategy 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - bash/.bashrc: replace oh-my-bash with minimal unified config sources common → aliases → OS overlay → .bashrc.local - zsh/.zshrc: remove hardcoded macOS PATHs (moved to macos overlay) clean sourcing order: common → personal → aliases → OS → .zshrc.local - shell/common: populated with universal exports (EDITOR, HISTSIZE, etc.) - shell/macos: Homebrew, Antigravity, Flutter PATH, fzf init, macOS aliases - shell/linux: xdg-open, xclip, fzf init for Linux - nvim/plugins/work.lua: Copilot plugin (migrated from origin/work branch) - nvim/plugins/_init.lua: conditional load via DOTFILES_PROFILE=work env var - tmux/.tmux.conf.local: per-machine override hook (~/.tmux.conf.machine.local) - bootstrap.sh: one-command new machine setup with profile support usage: bash bootstrap.sh [personal|work] - .gitignore: comprehensive .local file ignore patterns All branches (linux, mac, work, linux_personal, linux_work, mac_personal) can now be deleted — all unique content is merged into master. --- .gitignore | 13 ++ bash/.bashrc | 186 +++--------------- bootstrap.sh | 85 ++++++++ .../nvim/lua/kickstart/plugins/_init.lua | 6 +- .../nvim/lua/kickstart/plugins/work.lua | 8 + shell/.config/shell/common | 13 ++ shell/.config/shell/linux | 21 ++ shell/.config/shell/macos | 19 ++ tmux/.tmux.conf.local | 7 + zsh/.zshrc | 28 ++- 10 files changed, 215 insertions(+), 171 deletions(-) create mode 100644 bootstrap.sh create mode 100644 nvim/.config/nvim/lua/kickstart/plugins/work.lua create mode 100644 shell/.config/shell/linux create mode 100644 shell/.config/shell/macos diff --git a/.gitignore b/.gitignore index 951142f..d19dc6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,15 @@ +# ── Neovim lock file ────────────────────────────────────────────────────────── *nvim/.config/nvim/lazy-lock.json* + +# ── OS clutter ──────────────────────────────────────────────────────────────── .DS_Store +Thumbs.db + +# ── Per-machine local overrides (Strategy 1: Dynamic Runtime Sourcing) ──────── +# These files are stowed/created on each machine but never committed. +# They contain secrets, host-specific paths, work credentials, etc. +**/*.local +**/.zshrc.local +**/.tmux.conf.local +**/.gitconfig.local +**/.env.local diff --git a/bash/.bashrc b/bash/.bashrc index 220766a..869e932 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -7,171 +7,37 @@ case $- in *) return;; esac -# Path to your oh-my-bash installation. -export OSH='$HOME/.oh-my-bash' +# ── Shared shell config ──────────────────────────────────────────────────────── +[[ -f ~/.config/shell/common ]] && source ~/.config/shell/common +[[ -f ~/.config/shell/aliases ]] && source ~/.config/shell/aliases -# Set name of the theme to load. Optionally, if you set this to "random" -# it'll load a random theme each time that oh-my-bash is loaded. -OSH_THEME="font" +# ── OS detection — source the right platform overlay ────────────────────────── +case "$(uname -s)" in + Darwin) [[ -f ~/.config/shell/macos ]] && source ~/.config/shell/macos ;; + Linux) [[ -f ~/.config/shell/linux ]] && source ~/.config/shell/linux ;; +esac -# If you set OSH_THEME to "random", you can ignore themes you don't like. -# OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") -# You can also specify the list from which a theme is randomly selected: -# OMB_THEME_RANDOM_CANDIDATES=("font" "powerline-light" "minimal") +# ── Bash-specific init (starship, zoxide, fzf) ──────────────────────────────── +if [[ -n "$BASH_VERSION" ]]; then + # History settings + HISTCONTROL=ignoreboth + HISTSIZE=10000 + HISTFILESIZE=20000 + shopt -s histappend checkwinsize -# Uncomment the following line to use case-sensitive completion. -OMB_CASE_SENSITIVE="true" + # Starship prompt + command -v starship >/dev/null && eval "$(starship init bash)" -# Uncomment the following line to use hyphen-insensitive completion. Case -# sensitive completion must be off. _ and - will be interchangeable. -OMB_HYPHEN_SENSITIVE="false" + # Zoxide (smarter cd) + command -v zoxide >/dev/null && eval "$(zoxide init bash)" -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to change how often to auto-update (in days). -export UPDATE_OSH_DAYS=13 - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you don't want the repository to be considered dirty -# if there are untracked files. -# SCM_GIT_DISABLE_UNTRACKED_DIRTY="true" - -# Uncomment the following line if you want to completely ignore the presence -# of untracked files in the repository. -# SCM_GIT_IGNORE_UNTRACKED="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. One of the following values can -# be used to specify the timestamp format. -# * 'mm/dd/yyyy' # mm/dd/yyyy + time -# * 'dd.mm.yyyy' # dd.mm.yyyy + time -# * 'yyyy-mm-dd' # yyyy-mm-dd + time -# * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors -# * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors -# * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors -# If not set, the default value is 'yyyy-mm-dd'. -# HIST_STAMPS='yyyy-mm-dd' - -# Uncomment the following line if you do not want OMB to overwrite the existing -# aliases by the default OMB aliases defined in lib/*.sh -# OMB_DEFAULT_ALIASES="check" - -# Would you like to use another custom folder than $OSH/custom? -# OSH_CUSTOM=/path/to/new-custom-folder - -# To disable the uses of "sudo" by oh-my-bash, please set "false" to -# this variable. The default behavior for the empty value is "true". -OMB_USE_SUDO=true - -# To enable/disable display of Python virtualenv and condaenv -# OMB_PROMPT_SHOW_PYTHON_VENV=true # enable -# OMB_PROMPT_SHOW_PYTHON_VENV=false # disable - -# To enable/disable Spack environment information -# OMB_PROMPT_SHOW_SPACK_ENV=true # enable -# OMB_PROMPT_SHOW_SPACK_ENV=false # disable - -# Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*) -# Custom completions may be added to ~/.oh-my-bash/custom/completions/ -# Example format: completions=(ssh git bundler gem pip pip3) -# Add wisely, as too many completions slow down shell startup. -completions=( - git - composer - ssh -) - -# Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*) -# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/ -# Example format: aliases=(vagrant composer git-avh) -# Add wisely, as too many aliases slow down shell startup. -aliases=( - general -) - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*) -# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=( - git - bashmarks - starship -) - -# Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*) -# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ -# Example format: -# if [ "$DISPLAY" ] || [ "$SSH" ]; then -# plugins+=(tmux-autoattach) -# fi - -# If you want to reduce the initialization cost of the "tput" command to -# initialize color escape sequences, you can uncomment the following setting. -# This disables the use of the "tput" command, and the escape sequences are -# initialized to be the ANSI version: -# -#OMB_TERM_USE_TPUT=no - -source "$OSH"/oh-my-bash.sh - -# User configuration -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# ssh -# export SSH_KEY_PATH="~/.ssh/rsa_id" - -# Set personal aliases, overriding those provided by oh-my-bash libs, -# plugins, and themes. Aliases can be placed here, though oh-my-bash -# users are encouraged to define aliases within the OSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias bashconfig="mate ~/.bashrc" -# alias ohmybash="mate ~/.oh-my-bash" -# test if the prompt var is not set and also to prevent failures -# when `$PS1` is unset and `set -u` is used -if [ -z "${PS1:-}" ]; then -# prompt var is not set, so this is *not* an interactive shell - return + # fzf + [[ -f ~/.fzf.bash ]] && source ~/.fzf.bash fi -# If we reach this line of code, then the prompt var is set, so -# this is an interactive shell. -# Put all the commands here that should run only if this is an -# interactive shell. +export EDITOR='nvim' +export MANROFFOPT="-c" -# Example command: -source ~/.config/shell/common -source ~/.config/shell/personal #added by 6500gitsetup -source ~/.config/shell/aliases +# ── Per-machine local override (untracked) ──────────────────────────────────── +# Create ~/.bashrc.local on each machine for secrets / host-specific tweaks. +[[ -f ~/.bashrc.local ]] && source ~/.bashrc.local diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..6f98e46 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# bootstrap.sh — Set up dotfiles on a new machine +# Usage: bash bootstrap.sh [--profile personal|work] +# +# This script stows all dotfile packages, copies shell config files, +# and creates untracked .local stub files for per-machine overrides. + +set -e +DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROFILE="${1:-personal}" + +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo " Dotfiles Bootstrap" +echo " Profile : $PROFILE" +echo " OS : $(uname -s)" +echo " Host : $(hostname)" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +# ── 1. Stow all packages ─────────────────────────────────────────────────────── +# shell is excluded from global .stow-local-ignore, handled separately below +PACKAGES="zsh bash tmux nvim starship alacritty kitty ghostty wezterm zed btop vim" + +for pkg in $PACKAGES; do + if [[ -d "$DOTFILES_DIR/$pkg" ]]; then + echo " stow → $pkg" + stow --adopt --dir="$DOTFILES_DIR" --target="$HOME" "$pkg" 2>/dev/null || \ + echo " ⚠ stow $pkg skipped (already linked or conflict)" + fi +done + +# ── 2. Copy shell config files manually (stow-local-ignore excludes `shell`) ── +SHELL_SRC="$DOTFILES_DIR/shell/.config/shell" +SHELL_DST="$HOME/.config/shell" +mkdir -p "$SHELL_DST" + +for f in common aliases personal work macos linux; do + if [[ -f "$SHELL_SRC/$f" ]]; then + echo " copy shell/$f → $SHELL_DST/$f" + cp -n "$SHELL_SRC/$f" "$SHELL_DST/$f" 2>/dev/null || true + fi +done + +# ── 3. Create untracked .local stub files ───────────────────────────────────── +create_stub() { + local file="$1" comment="$2" + if [[ ! -f "$file" ]]; then + echo "# $comment" > "$file" + echo " created stub → $file" + else + echo " exists (skipped) → $file" + fi +} + +create_stub "$HOME/.zshrc.local" "Per-machine zsh overrides — never committed" +create_stub "$HOME/.bashrc.local" "Per-machine bash overrides — never committed" +create_stub "$HOME/.tmux.conf.machine.local" "Per-machine tmux overrides — never committed" +create_stub "$HOME/.gitconfig.local" "Per-machine git identity — never committed" + +# ── 4. Inject profile into .zshrc.local if requested ────────────────────────── +if [[ "$PROFILE" == "work" ]]; then + if ! grep -q "DOTFILES_PROFILE" "$HOME/.zshrc.local" 2>/dev/null; then + echo "" >> "$HOME/.zshrc.local" + echo "# Work profile — load work-specific shell config and nvim plugins" >> "$HOME/.zshrc.local" + echo "export DOTFILES_PROFILE=work" >> "$HOME/.zshrc.local" + echo "source ~/.config/shell/work" >> "$HOME/.zshrc.local" + echo " → injected DOTFILES_PROFILE=work into ~/.zshrc.local" + fi +fi + +# ── 5. macOS-specific setup ─────────────────────────────────────────────────── +if [[ "$(uname -s)" == "Darwin" ]]; then + # Install Homebrew if missing + if ! command -v brew >/dev/null 2>&1; then + echo " Installing Homebrew…" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi +fi + +echo "" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo " Done! Next steps:" +echo " 1. Edit ~/.zshrc.local — add secrets / tokens" +echo " 2. Edit ~/.gitconfig.local — add your git identity for this machine" +echo " 3. Run: exec zsh (or source ~/.bashrc for bash)" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" diff --git a/nvim/.config/nvim/lua/kickstart/plugins/_init.lua b/nvim/.config/nvim/lua/kickstart/plugins/_init.lua index 21c646c..a9274af 100644 --- a/nvim/.config/nvim/lua/kickstart/plugins/_init.lua +++ b/nvim/.config/nvim/lua/kickstart/plugins/_init.lua @@ -75,7 +75,11 @@ require("lazy").setup({ "junegunn/seoul256.vim" }, - -- NOTE: Plugins can also be added by using a table, + -- ── Work-profile plugins (Copilot) ────────────────────────────────────── + -- Loaded only when DOTFILES_PROFILE=work is set (via ~/.zshrc.local). + -- On work machines add: export DOTFILES_PROFILE=work + (os.getenv("DOTFILES_PROFILE") == "work" and require("kickstart.plugins.work") or {}), + -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. -- diff --git a/nvim/.config/nvim/lua/kickstart/plugins/work.lua b/nvim/.config/nvim/lua/kickstart/plugins/work.lua new file mode 100644 index 0000000..f118663 --- /dev/null +++ b/nvim/.config/nvim/lua/kickstart/plugins/work.lua @@ -0,0 +1,8 @@ +-- Work-machine plugins (Copilot + CopilotChat) +-- Loaded only when DOTFILES_PROFILE=work is set in the environment. +-- Add this to your ~/.zshrc.local on work machines: +-- export DOTFILES_PROFILE=work +return { + "github/copilot.vim", + require("kickstart.plugins.copilot_chat"), +} diff --git a/shell/.config/shell/common b/shell/.config/shell/common index e69de29..353123c 100644 --- a/shell/.config/shell/common +++ b/shell/.config/shell/common @@ -0,0 +1,13 @@ +# ── Truly shared exports / env vars ─────────────────────────────────────────── +# Sourced by both .zshrc and .bashrc on ALL machines (all OSes, all profiles). +# Keep this minimal — only things that apply 100% universally. + +export EDITOR='nvim' +export VISUAL='nvim' + +# Man page rendering +export MANROFFOPT="-c" + +# Better history defaults (bash and zsh honour these) +export HISTSIZE=10000 +export HISTFILESIZE=20000 diff --git a/shell/.config/shell/linux b/shell/.config/shell/linux new file mode 100644 index 0000000..36ba466 --- /dev/null +++ b/shell/.config/shell/linux @@ -0,0 +1,21 @@ +# ── Linux-specific shell config ─────────────────────────────────────────────── +# Sourced automatically from .zshrc / .bashrc on Linux hosts only. + +# xdg-open alias (Linux equivalent of macOS `open`) +alias open="xdg-open" + +# Clipboard helpers (if xclip is present) +if command -v xclip >/dev/null 2>&1; then + alias pbcopy="xclip -selection clipboard" + alias pbpaste="xclip -selection clipboard -o" +fi + +# fzf shell integration (Linux path) +[[ -f /usr/share/doc/fzf/examples/key-bindings.zsh ]] && \ + source /usr/share/doc/fzf/examples/key-bindings.zsh +[[ -f ~/.fzf.zsh ]] && source ~/.fzf.zsh + +# Zoxide (smarter cd) — in case not already initialized by bashrc +if [[ -n "$ZSH_VERSION" ]]; then + command -v zoxide >/dev/null && eval "$(zoxide init zsh)" +fi diff --git a/shell/.config/shell/macos b/shell/.config/shell/macos new file mode 100644 index 0000000..3c1f20e --- /dev/null +++ b/shell/.config/shell/macos @@ -0,0 +1,19 @@ +# ── macOS-specific shell config ─────────────────────────────────────────────── +# Sourced automatically from .zshrc / .bashrc on Darwin hosts only. + +# Homebrew +eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null +export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" + +# Antigravity +export PATH="/Users/jsarthak/.antigravity/antigravity/bin:$PATH" + +# Flutter SDK +export PATH="/Users/jsarthak/flutter-sdk/flutter/bin:$PATH" + +# fzf shell integration (macOS path) +source <(fzf --zsh) 2>/dev/null || true + +# macOS convenience aliases +alias finder="open -a Finder ." +alias brewup="brew update && brew upgrade && brew cleanup" diff --git a/tmux/.tmux.conf.local b/tmux/.tmux.conf.local index 4d52a6a..13adbb4 100644 --- a/tmux/.tmux.conf.local +++ b/tmux/.tmux.conf.local @@ -366,6 +366,13 @@ source-file "/Users/jsarthak/dotfiles/tmux/config/keybindings.conf" setw -g window-status-separator " #[fg=#484848]• " #!important +# ── Per-machine local override (untracked) ──────────────────────────────────── +# Create ~/.tmux.conf.machine.local on each machine for host-specific tweaks +# (e.g. different color scheme, right-side content, etc.) +if-shell 'test -f ~/.tmux.conf.machine.local' \ + 'source-file ~/.tmux.conf.machine.local' + + # -- tpm ----------------------------------------------------------------------- # while I don't use tpm myself, many people requested official support so here diff --git a/zsh/.zshrc b/zsh/.zshrc index 0329c27..e3ea2a1 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -103,18 +103,26 @@ fi # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" -export PATH="/Users/jsarthak/flutter-sdk/flutter/bin:$PATH" -source <(fzf --zsh) - -# Added by Antigravity -export PATH="/Users/jsarthak/.antigravity/antigravity/bin:$PATH" -export PATH="/Users/jsarthak/flutter-sdk/flutter/bin:$PATH" -export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" -source ~/.config/shell/common -source ~/.config/shell/personal -source ~/.config/shell/aliases +# ── Shared shell config ──────────────────────────────────────────────────────────────── +[[ -f ~/.config/shell/common ]] && source ~/.config/shell/common +[[ -f ~/.config/shell/personal ]] && source ~/.config/shell/personal +[[ -f ~/.config/shell/aliases ]] && source ~/.config/shell/aliases MANPAGER="col -b | cat" MANROFFOPT="-P-c" eval "$(zoxide init zsh)" + +# ── Strategy 1: Dynamic Runtime Sourcing ───────────────────────────────────────── +# Detect OS and source the matching platform overlay. +# macos → shell/.config/shell/macos (Homebrew, Flutter, fzf, Antigravity) +# linux → shell/.config/shell/linux (xdg-open, xclip, fzf) +case "$(uname -s)" in + Darwin) [[ -f ~/.config/shell/macos ]] && source ~/.config/shell/macos ;; + Linux) [[ -f ~/.config/shell/linux ]] && source ~/.config/shell/linux ;; +esac + +# ── Per-machine local override (untracked) ────────────────────────────────── +# Create ~/.zshrc.local on each machine for secrets / profile sourcing. +# On work machines: export DOTFILES_PROFILE=work && source ~/.config/shell/work +[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local