CodeRabbit Dotfiles

repository·master·Indexed 41 days ago

https://github.com/coderabbitai/dotfiles

A highly optimized development environment for CodeRabbit engineers. Features pre-configured Neovim, tmux, zsh, and Homebrew setups designed for modern language development. Includes utilities for bulk-cloning GitHub organization repositories, automated system updates via autoupdate.zsh, and the git_ship CLI for streamlined commit and push workflows.

Tokens
5K
Snippets
18
Records
26
Agent score
47%

What's inside CodeRabbit Dotfiles

  1. Manage tmux sessions and features

    master

    tmux sessions start automatically when .zshrc is executed.

    Key Bindings and Shortcuts

    • Prefix: C-a or C-b
    • Fuzzy Menu: C-a C-Space (quick management and shortcuts).
    • Management Menu: F12 (session/window/pane management).
    • Suspend/Unsuspend local tmux: F1 (useful for remote SSH sessions).
    • Fuzzy search terminal buffer: C-a C-/
    • Facebook PathPicker: C-a C-P (select a line from scrollback to use in another command).
    • Urlview: C-a C-U (select a URL from scrollback to open in browser).

    Note: Vi bindings are enabled in tmux copy mode.

  2. Install CodeRabbit Dotfiles

    master

    You can install the optimized development environment using either an automatic script or a manual chezmoi setup.

    Automatic Setup

    Run the following command to execute the installation script:

    Manual Setup

    If you prefer manual control using chezmoi:

    1. Initialize the repository in your home directory.
    2. Review the changes that will be applied.
    3. Apply the changes.

    Note: After installation, close and reopen your terminal to trigger the first-time setup. It is recommended to authenticate with GitHub using the GitHub CLI (gh auth login) or by adding an SSH key to your GitHub account.

    # Automatic Setup
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/coderabbitai/dotfiles/master/sw/assets/executable_install.sh)"
    
    # Manual Setup
    cd $HOME
    chezmoi init git@github.com:coderabbitai/dotfiles.git
    chezmoi diff
    chezmoi apply -v
  3. Configure Neovim settings and plugins

    master

    Neovim is configured for modern development (Golang, TypeScript, etc.). You can extend it using local files:

    • vimrc settings: Add to $HOME/.vimrc_local.
    • Plugins: Add to $HOME/.vimrc_plugins.
    • Colorschemes: The default is gruvbox. To override, add let colorscheme = <colorscheme> to your .vimrc_local.
    • FuzzyMenu: Press <space><space> or Shift + LeftMouse click to open a contextual menu for settings or plugins.

    AI Features

    • GitHub Copilot: Run :Copilot setup inside Neovim.
    • CodeGPT: Highlight code and press <space><space> to see options. Requires the OPENAI_API_KEY environment variable to be set in $HOME/.zshrc_local.
  4. Override terminal and tool colors

    master

    The environment defaults to a gruvbox-dark palette. You can override individual components via local files or environment variables:

    • Terminal Colors:
      • macOS (iTerm2): Install the bundled profile or use terminal escape codes. Set SET_TERMINAL_COLORS=false in .zshrc_local to use your own profile.
      • Linux: Use $HOME/sw/assets/install_gruvbox.sh or set SET_TERMINAL_COLORS=false in .zshrc_local.
    • tmux theme: Override in .tmux.conf_local.
    • bat theme: Set the BAT_THEME environment variable in .zshrc_local.
    • LS_COLORS: Use vivid to set themes; override in .zshrc_local.
    • Git pager: Override in .gitconfig_local.
    • Fast Syntax Highlighting (zsh): Set FAST_WORK_DIR to $HOME/.config/fsh_local in .zshrc, then run fast-theme <theme>.
  5. Package installation logic for Brews and Casks

    master

    The script optimizes installation by first fetching packages in parallel using parallel before performing sequential installations to allow for progress tracking via revolver.

    Formulae (Brews) Workflow:

    1. Fetches all required formulae in parallel: parallel ... brew fetch --quiet --formula {1} ...
    2. Installs each package sequentially: brew install --quiet --formula $package

    Casks Workflow:

    1. Fetches all required casks in parallel: parallel ... brew fetch --quiet --cask {1} ...
    2. Installs each cask sequentially: brew install --quiet --cask $cask
  6. Configure Git username and local settings

    master

    To set your Git identity and GitHub credentials, create a .gitconfig_local file in your home directory. You can also store your GitHub personal access token in your $HOME/.netrc file to enable HTTP API access.

    Example .gitconfig_local structure:

    To add a token to .netrc: echo 'machine api.github.com login <user> password <token>' >> $HOME/.netrc

    [user]
      name = Harjot Gill
      email = harjot@coderabbit.ai
    [github]
       user = <github user name>
       token = <personal access token>
  7. Customize Autoupdates and zshrc

    master

    The environment supports local overrides for core configurations:

    • Autoupdates: The environment autoupdates every 7 days. You can trigger a manual update with autoupdate.zsh --force. To provide custom autoupdate commands, add them to $HOME/.autoupdate_local.zsh.
    • zshrc: To add additional zsh settings, use the $HOME/.zshrc_local file.
  8. Extend the autoupdate process with a local script

    master

    You can add custom update commands to the automated workflow by creating a file named ~/.autoupdate_local.zsh. The main script checks for this file's existence and executes its content using eval. If the local script returns a non-zero exit code, it will be reported as an error at the end of the process.

    # Create ~/.autoupdate_local.zsh to run custom commands
    echo 'echo "Running my custom updates..."' > ~/.autoupdate_local.zsh
    echo 'brew upgrade my-special-tool' >> ~/.autoupdate_local.zsh
  9. Synchronize Fluxninja configurations and tools

    master

    The executable_sync_fluxninja.sh script automates the setup and synchronization of the Fluxninja development environment. It performs the following high-level tasks:

    1. Repository Management: Clones all Fluxninja repositories into ~/Work using gh_clone_all.sh and updates them using pull_all.sh.
    2. Symlinking: Creates necessary symlinks for aperture services and documentation content within the local workspace.
    3. Pre-commit Hooks: Installs pre-commit hooks (including pre-commit, commit-msg, and prepare-commit-msg types) across the cloud, aperture, and aperture-tech-docs directories.
    4. Toolchain Installation:
      • Aperture: Installs Go and Python tools via make, and synchronizes vale linting rules.
      • Aperture Tech Docs: Runs yarn install and synchronizes vale rules.
      • Fluxninja Website: Runs yarn install.
      • Opsninja: Installs the local package using pip3 install ..

    Note: This script assumes gh_clone_all.sh and pull_all.sh are available in your path or environment.

    ./sw/bin/executable_sync_fluxninja.sh
  10. Use git_ship for streamlined git workflows

    master

    The git_ship command is a CLI utility designed to automate the process of committing and pushing changes. It provides a guided workflow that includes:

    1. Pre-flight checks: Verifies that the branch is not in a merging state and displays modified and untracked files.
    2. Interactive Commit Messages:
      • Allows passing a message as a direct argument.
      • Offers to repeat the last commit message used in the current repository.
      • If no message is provided, it uses gum to prompt for a conventional commit type (fix, feat, docs, style, refactor, test, chore, revert) and then prompts for the message text.
    3. Resilient Committing: Attempts to commit changes with a retry mechanism (up to 3 attempts) if the initial commit fails (e.g., due to transient locks), provided the failure doesn't happen instantly.
    4. Automated Sync: Automatically performs a git pull --rebase followed by a git push -u to the current upstream branch.

    Dependencies:

    • git
    • gum (for interactive prompts)
    • revolver (for progress indicators/animations)
    # Commit with a specific message
    ./executable_git_ship "feat: add new login logic"
    
    # Commit using the interactive prompt (type selection and message input)
    ./executable_git_ship
    
    # Commit while skipping git hooks (no-verify)
    ./executable_git_ship --no-verify "chore: update dependencies"
  11. Synchronize CodeRabbit configurations and dependencies

    master

    The executable_sync_coderabbitai.sh script automates the setup of the CodeRabbit development environment. It performs the following sequence of actions:

    1. Clones and Updates Repositories: It calls gh_clone_all.sh to ensure all coderabbitai repositories are cloned into ~/Work, and then calls pull_all.sh to update them.
    2. Dependency Installation: It traverses subdirectories within ~/Work/coderabbitai looking for package.json files. For each directory found, it automatically selects and runs the appropriate package manager based on the existing lockfile:
      • Uses pnpm install if pnpm-lock.yaml is present.
      • Uses yarn install if yarn.lock is present.
      • Uses npm install if package-lock.json is present.
    3. Git Hook Setup: If the directory ~/Work/coderabbitai/mono exists, it runs the husky command to install git hooks.

    Note: This script assumes that gh_clone_all.sh, pull_all.sh, and the respective package managers (pnpm, yarn, npm) are available in your PATH.

    ./sw/bin/executable_sync_coderabbitai.sh
  12. Synchronize Homebrew packages and system configuration

    master

    The executable_sync_brews.sh script automates the synchronization of a development environment by installing Homebrew formulae, casks, fonts, and language-specific packages (Go, NPM, Python). It uses revolver for progress visualization and parallel to speed up package fetching.

    Key behaviors:

    • Non-interactive mode: Sets HOMEBREW_NO_ASK=1 and HOMEBREW_NO_REQUIRE_TAP_TRUST=1 to prevent blocking during installation.
    • Platform Specifics:
      • On macOS (darwin): Installs a wide range of casks (e.g., iTerm2, Docker, VS Code), sets iTerm2 as the default terminal via duti, and configures OpenJDK 17 symlinks.
      • On Linux: Sets the default editor to nvim via xdg-mime and installs Linux-specific dependencies like xclip and libnotify.
    • Font Installation: Automatically downloads and installs Nerd Fonts from GitHub if they are missing from ~/.local/share/fonts.
    • Tooling Setup: Configures fzf, updates tldr pages, clones navi cheats, and installs various global packages for Go, NPM, and Python.
    #!/usr/bin/env zsh
    ./executable_sync_brews.sh