### Install Dependencies and Backup Dotfiles Source: https://github.com/wxh16144/dotfiles/blob/master/readme.md This command installs the necessary Node.js dependencies for the project and then executes a backup script, likely to create or update the configuration backups. ```bash npm install && npm run backup ``` -------------------------------- ### Install Dependencies and Create Initial Backup (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt This script clones the dotfiles repository, installs npm dependencies, and then creates an initial backup of the current system configurations using the 'backup' npm script. ```bash # Clone from template branch git clone --branch template --depth 1 git@github.com:Wxh16144/dotfiles.git cd dotfiles # Install dependencies npm install # Create initial backup of current system configurations npm run backup ``` -------------------------------- ### Backup Configuration (.backuprc) Example Source: https://context7.com/wxh16144/dotfiles/llms.txt An example INI-formatted configuration file for backup settings, specifying the storage directory and applications to synchronize, including overrides and custom handlers. ```ini [storage] directory=backup [applications_to_sync] vscode ... ``` -------------------------------- ### Install Project Dependencies using npm Source: https://github.com/wxh16144/dotfiles/blob/master/readme.en.md This command installs the necessary Node.js dependencies for the project. It assumes that npm is installed and available in the environment. This is a prerequisite for running project scripts. ```bash npm install ``` -------------------------------- ### Frontend Development Workflow (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt Provides bash scripts for starting, building, and managing frontend projects. It automates common npm/yarn commands and handles dependency reinstallation with registry configuration. ```bash # Start frontend project (auto-detects start/dev script) s # Runs: npm run start OR npm run dev (whichever exists) # Build frontend project b # Runs: npm run build OR npm run compile (whichever exists) # Shows success celebration if build succeeds # Reinstall dependencies with cleanup rei # Removes all node_modules # Cleans lock files (with -l flag) # Sets registry to taobao mirror # Reinstalls dependencies # Usage: rei -l (removes lock files too) # Quick project creation project vite-react-ts_antd5 # Creates temp directory with symlink to $PLAY # Initializes Vite React TypeScript project # Auto-installs dependencies based on name: # - antd5: antd@5 + icons + antd-style # - antd4: antd@4 + icons # - antdpro: antd + pro-components # - mui: Material-UI + emotion # Opens VSCode and starts dev server ``` -------------------------------- ### Git Workflow Function: Clone Repository and Setup Remotes (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt A bash function 'cloneoss' that clones a given repository, sets up upstream and origin remotes for forked repositories, and automatically opens the Fork application. ```bash # Clone repository and setup upstream cloneoss git@github.com:ant-design/ant-design.git # Clones to $OSS/ant-design # Sets up origin (your fork), upstream (original), and fork remotes # Opens Fork app automatically ``` -------------------------------- ### Bootstrap Script for GitHub Codespaces (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt This bash script is designed to bootstrap a development environment, particularly for GitHub Codespaces. It verifies the Node.js version, pulls the latest changes, installs dependencies, and forces a restore of all configurations. ```bash # Run bootstrap script (for GitHub Codespaces or fresh environments) ./bootstrap.sh # This script will: # - Verify Node.js version (requires v18+) # - Pull latest changes from master branch # - Install npm dependencies # - Force restore all configurations from backup ``` -------------------------------- ### Zsh Plugin and Theme Configuration (.zshrc) Source: https://context7.com/wxh16144/dotfiles/llms.txt Configuration snippet for `.zshrc` file, defining Zsh plugins to be loaded, including community plugins requiring manual installation, and setting the Zsh theme. ```bash # .zshrc plugins configuration plugins=( git git-flow # Community plugins (require installation) zsh-autosuggestions # git clone to $ZSH_CUSTOM/plugins/ fast-syntax-highlighting # git clone to $ZSH_CUSTOM/plugins/ spaceship-react # git clone to $ZSH_CUSTOM/plugins/ z.lua # git clone to $ZSH_CUSTOM/plugins/ ) # Theme configuration ZSH_THEME="spaceship" ``` -------------------------------- ### Custom Zsh Aliases for Development Workflow Source: https://context7.com/wxh16144/dotfiles/llms.txt A collection of custom Zsh aliases designed to streamline various development tasks on macOS. This includes safety measures for `rm`, application shortcuts, directory navigation helpers, package manager commands, Git shortcuts, and utility functions for tasks like clearing the screen or copying the current path. Some aliases rely on external tools like `trash` (brew install trash) or specific project structures. ```shell # Safety aliases rm # Blocked - use rmm or /bin/rm rmm # Uses trash command (brew install trash) # Application shortcuts st # Open SourceTree f # Open Fork app in current git repo fk # Prevent Mac from sleeping (1 hour) # Directory navigation w # cd $WORKSPACE com # cd $COMPANY oss # cd $OSS my # cd $MY play # cd $PLAY # Package manager shortcuts i # ni (smart package install) rei # Reinstall all dependencies s # Start frontend project b # Build frontend project lintf # Run lint with --fix # Git shortcuts clone # clone_and_cd function gbsw # Switch to main, pull, switch back gfix # Fixup commit and rebase garc # Archive commit by hash gbp # Create backup branch # Utility shortcuts c # Clear screen completely o # open . cpwd # Copy current path to clipboard big # Show largest directories cl # Count lines of code ``` -------------------------------- ### Create Backup of Current System (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt This command initiates a backup of all configured applications based on the .backuprc file. It covers settings for VSCode, iTerm2, Zsh/Bash, Git, package managers, Homebrew, and custom application configurations. ```bash # Backup all configured applications npm run backup # This reads .backuprc configuration and backs up files from: # - VSCode settings and snippets # - iTerm2 configuration # - Zsh/Bash configurations # - Git config # - npm/yarn/pnpm settings # - Homebrew packages # - Custom application configs ``` -------------------------------- ### Safe Restore Implementation Logic (JavaScript) Source: https://context7.com/wxh16144/dotfiles/llms.txt This Node.js script implements the safe restore logic. It uses simple-git to check repository status, creates a backup, stashes changes if necessary, and then executes a restore operation with force restore enabled via an environment variable. ```javascript // scripts/safe-restore.js const simpleGit = require('simple-git'); const { spawnSync } = require('child_process'); const path = require('path'); const git = simpleGit({ baseDir: path.join(__dirname, '..') }); async function run() { // Verify git repository if (!await git.checkIsRepo()) { return console.log('Not a git repository'); } // Check working tree is clean if (!(await git.status()).isClean()) { return console.log('Working tree is not clean'); } const currentBranch = await git.branchLocal().then(({ current }) => current); const currentCommit = (await git.revparse(['HEAD'])).slice(0, 7); // Backup current state spawnSync('node', [script, '-f'], { stdio: 'inherit' }); // Stash if there are changes if (!(await git.status()).isClean()) { const title = `WIP on ${currentBranch}(${currentCommit}): ${new Date().toLocaleString()}`; await git.stash(['save', '-u', title]); } // Restore configurations process.env.BACKUP_FORCE_RESTORE = 'true'; spawnSync('node', [script, '-r', '-f'], { stdio: 'inherit' }); } run().catch(console.error); ``` -------------------------------- ### Network and Server Utilities (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt Scripts for setting up local servers with ngrok tunnels, private servers, retrieving public and local IP addresses, and killing processes on specific ports. ```bash # Quick local server with ngrok tunnel ser coverage 8080 # Serves ./coverage directory on port 8080 # Creates ngrok public URL # Generates QR codes for both local and public URLs # Shows ngrok inspect interface at localhost:4040 # Private server (no ngrok) pser . 3000 # Serves current directory on port 3000 # Only shows local network URL with QR code # No public tunnel created # Get public IP addresses ip # Queries multiple IP services: # - api.ipaddress.com # - api.ipify.org # - ipinfo.io/ip # - ifconfig.me/ip # Get local network IP ipl # Shows all local network interface IPs # Example output: 192.168.1.100 # Kill process on port portkill 3000 # Finds and kills process listening on port 3000 ``` -------------------------------- ### NPM Registry Management (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt Allows easy switching between different npm registries like taobao, npm, and custom company registries. It also shows the current registry and provides options for resetting. ```bash # Switch npm registry nrr taobao # Switch to taobao mirror nrr npm # Switch to official npm nrr # Show current registry and prompt to reset # Custom registries via environment variables export COMPANY_NPM_REGISTRY="https://npm.company.com" nrr company # Will use COMPANY_NPM_REGISTRY # Available registries: # - npm: https://registry.npmjs.org/ # - yarn: https://registry.yarnpkg.com/ # - taobao: https://registry.npmmirror.com/ # - cnpm: https://r.cnpmjs.org/ # - tencent: https://mirrors.cloud.tencent.com/npm/ ``` -------------------------------- ### Apply Configurations using npm Source: https://github.com/wxh16144/dotfiles/blob/master/readme.en.md This command executes a script within the project to restore or apply the stored dotfile configurations. It relies on the project's npm scripts and pre-installed dependencies. ```bash npm run restore ``` -------------------------------- ### Custom Backup Script Wrapper (JavaScript) Source: https://context7.com/wxh16144/dotfiles/llms.txt A Node.js script that acts as a wrapper for the backup-cli. It configures the environment variables for backup-cli and executes it with specified arguments, allowing for custom backup operations. ```javascript // scripts/sync.js - Custom backup wrapper const path = require('path'); const { execSync } = require('child_process'); // Configure backup-cli environment process.env.BACKUP_CONFIG_FILE = path.resolve(__dirname, '../.backuprc'); process.env.BACKUP_CUSTOM_APP_DIR = path.resolve(__dirname, '../.backup'); process.env.BACKUP_UPSTREAM_HOME = '/Users/wuxh'; // Execute backup-cli with arguments const backupCli = require.resolve('@wuxh/backup-cli'); const args = process.argv.slice(2); execSync(`node ${backupCli} ${args.join(' ')}`, { stdio: 'inherit' }); ``` -------------------------------- ### Git Workflow Function: Create Branch Backup (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt A bash function 'gbp' that creates a backup branch with a timestamp and commits all changes with detailed metadata. It can optionally push the backup branch to the remote. ```bash # Create branch backup with automatic commit message gbp # Creates backup branch: {username}/backup/{timestamp} # Example: wuxh/backup/2025-10-22-14_30_45 # Commits all changes with detailed metadata # Optionally push to remote with: gbp -r ``` -------------------------------- ### File and Directory Management (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt Provides utility functions for creating temporary and persistent directories, cloning repositories into temporary locations, safely deleting directories, and counting lines of code. ```bash # Create temporary directory with cleanup dirt my-experiment # Creates temp dir: /tmp/{username}_tmp_{hash} # Creates symlink in $PLAY directory # Auto-cleans broken symlinks # Removed on system restart # Create persistent play directory dirp test-feature # Creates dir in $TMPPLAY (persists across restarts) # No symlink created # Useful for longer-term experiments # Clone to temporary directory clonet git@github.com:ant-design/ant-design.git feature-branch # Clones with --depth=1 (no history) # Creates temp dir with symlink # Switches to specified branch # Delete directory safely del ./old-project # Prompts for confirmation # Uses trash for non-temp directories # Uses rm for temp dirs and symlinks # Navigates to parent after deletion # Count lines of code cl src/ # Recursively counts lines in all files # Ignores: node_modules, .git, dist, es, lib # Sorts by line count (descending) # Shows top 300 files ``` -------------------------------- ### Clone Dotfiles using Git Source: https://github.com/wxh16144/dotfiles/blob/master/readme.en.md This command clones the dotfiles repository from GitHub to the local machine and navigates into the newly created directory. It is the initial step for setting up the configurations. ```bash git clone git@github.com:Wxh16144/dotfiles.git && cd dotfiles ``` -------------------------------- ### Safe Restore of Configurations (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt This command performs a safe restore of configurations. It checks for a clean working tree, creates a backup of the current state, stashes any uncommitted changes, and then restores configurations from the backup directory. ```bash # Safe restore (recommended for existing configurations) npm run restore # This will: # 1. Check if working tree is clean # 2. Create backup of current state # 3. Stash any uncommitted changes # 4. Restore configurations from backup directory # 5. Preserve your existing work in git stash ``` -------------------------------- ### Clone Dotfiles Repository Source: https://github.com/wxh16144/dotfiles/blob/master/readme.md This command clones the dotfiles repository with the 'template' branch and a depth of 1, suitable for initializing a new project with the provided dotfiles. ```bash git clone --branch template --depth 1 git@github.com:Wxh16144/dotfiles.git ``` -------------------------------- ### Git Branch Management (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt Handles git operations including switching to the main branch, pulling the latest changes, and returning to the previous branch. It can optionally rebase and archives commit snapshots. ```bash # Switch to main branch, pull, and return gbsw # Saves current branch, switches to main, pulls, switches back # Optionally rebase: answers 'y' when prompted # Archive commit snapshot garc abc1234 # Creates tar.gz archive in ./archive/ # Copies path to clipboard # Prompts to open archive directory ``` -------------------------------- ### Node Modules Management (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt Scripts to list all `node_modules` directories within a project and to remove them, either interactively or automatically. It uses `rm` for efficiency. ```bash # List all node_modules directories lsnm # Finds all node_modules in current directory tree # Output: ./node_modules, ./packages/foo/node_modules, etc. # Remove all node_modules rmnm # Interactive: prompts for each directory rmnm -a # Automatic: removes all without prompts # Uses /bin/rm (not trash) to save space ``` -------------------------------- ### Package.json Scripts Configuration (JSON) Source: https://context7.com/wxh16144/dotfiles/llms.txt A JSON object defining npm scripts in `package.json`, including commands for backup, restore, and synchronization operations, some of which utilize external scripts and environment variables. ```json { "scripts": { "start": "npm run backup", "backup": "npm run . -- -df", "restore": "npm run safe-restore", "safe-restore": "node ./scripts/safe-restore.js", "unsafe-restore": "node ./scripts/sync.js -drf", "force-restore": "BACKUP_FORCE_RESTORE='true' npm run unsafe-restore", ".": "node ./scripts/sync.js" } } ``` -------------------------------- ### Force Restore Configurations (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt This command forcefully restores all configurations, overwriting any existing files. It's a dangerous operation and should only be used when the consequences are fully understood. ```bash # Force restore all configurations (overwrites existing files) npm run force-restore # WARNING: This will overwrite your current configurations # Only use if you understand the consequences ``` -------------------------------- ### Zsh Environment and Alias Loading Source: https://context7.com/wxh16144/dotfiles/llms.txt Loads custom environment variables and aliases from separate Zsh files into the current shell session. It also sets default language and locale settings for UTF-8 compatibility. Ensure the specified paths for `custom_env.zsh` and `custom_alias.zsh` exist within your Zsh custom directory. ```shell # Custom configurations loaded at startup source "$ZSH_CUSTOM/custom_env.zsh" # Environment variables source "$ZSH_CUSTOM/custom_alias.zsh" # Aliases and functions # Language settings export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 ``` -------------------------------- ### Git Workflow Function: Fix Previous Commit (Bash) Source: https://context7.com/wxh16144/dotfiles/llms.txt A bash function 'gfix' that stages all changes and then performs a fixup commit, automatically rebasing to squash it with the previous commit. It can also be used with a specific commit hash. ```bash # Fix previous commit and auto-squash git add . gfix # Commits as fixup and rebases automatically # Use with specific hash: gfix abc1234 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.