diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a31bd63..073b0f1 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,29 +1,33 @@ -# This is a basic workflow to help you get started with Actions - name: Linux -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "main" branch push: branches: ["main"] pull_request: branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - linux-test: - # The type of runner that the job will run on + install-legacy: + name: Install Legacy (Linux) runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run install_and_configure.sh + run: bash install_and_configure.sh - # Steps represent a sequence of tasks that will be executed as part of the job + install-bootstrap: + name: Install Bootstrap (Linux) + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Run bootstrap.sh --non-interactive + run: bash bootstrap.sh --non-interactive - # Runs install script - - name: Run install_and_configure.sh - run: ${GITHUB_WORKSPACE}/install_and_configure.sh + test: + name: Tests (Linux) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run test suite + run: bash tests/run_tests.sh diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 0c64e05..0f88c66 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,29 +1,33 @@ -# This is a basic workflow to help you get started with Actions +name: macOS -name: MacOS - -# Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "main" branch push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] - - # Allows you to run this workflow manually from the Actions tab + branches: ["main"] workflow_dispatch: -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - macos-test: - # The type of runner that the job will run on + install-legacy: + name: Install Legacy (macOS) runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Run install_and_configure.sh + run: bash install_and_configure.sh - # Steps represent a sequence of tasks that will be executed as part of the job + install-bootstrap: + name: Install Bootstrap (macOS) + runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Run bootstrap.sh --non-interactive + run: bash bootstrap.sh --non-interactive - # Runs install script - - name: Run install_and_configure.sh - run: ${GITHUB_WORKSPACE}/install_and_configure.sh + test: + name: Tests (macOS) + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Run test suite + run: bash tests/run_tests.sh diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..84eccec --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,121 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Overview + +This is a dotfiles repository for setting up a development environment on macOS, Ubuntu/Debian, and WSL2. It includes configuration files for zsh, tmux, emacs, lsd, htop, neofetch, and yazi, along with an automated install script and a modular bootstrap system. + +## Repository Structure + +``` +dotfiles/ +├── bootstrap.sh ← NEW: interactive setup with feature selection +├── uninstall.sh ← NEW: one-command uninstall +├── install_and_configure.sh ← ORIGINAL: monolithic installer (DO NOT MODIFY — CI uses it) +├── modules/ +│ ├── lib.sh ← shared helpers (colors, OS detect, pkg_install, backup) +│ ├── core.sh ← existing tools: zsh/tmux/lsd/emacs/htop/neofetch/yazi +│ ├── shell.sh ← starship, fzf, zoxide, atuin +│ ├── dev.sh ← gh, ripgrep, direnv, bat, delta, fd, jq, lazygit +│ ├── node.sh ← fnm + Node LTS + commitizen +│ └── docker.sh ← Docker CE + docker compose +├── dotfiles/ +│ ├── .zshrc ← deployed to $HOME; has modular sourcing block appended +│ ├── .tmux.conf ← UNCHANGED +│ ├── .emacs.el ← UNCHANGED +│ ├── .gitmessage ← conventional commit template +│ ├── .zshrc.local.example ← secrets/local config template (copy to ~/.zshrc.local) +│ └── .zshrc.d/ +│ ├── fzf.zsh ← fzf keybindings + rg integration + helpers +│ ├── zoxide.zsh ← eval "$(zoxide init zsh)" +│ ├── starship.zsh ← eval "$(starship init zsh)" +│ ├── atuin.zsh ← eval "$(atuin init zsh --disable-up-arrow)" +│ ├── direnv.zsh ← eval "$(direnv hook zsh)" +│ ├── node.zsh ← fnm env initialization +│ ├── docker.zsh ← docker/compose aliases and helpers +│ └── commit.zsh ← git aliases + gcommit() + newproject() +├── config/ +│ ├── starship.toml ← two-line prompt with git/node/python info +│ └── atuin/ +│ └── config.toml ← fuzzy search, emacs keybindings, no auto-sync +├── templates/ +│ ├── node/ ← package.json, .gitignore stubs +│ └── python/ ← pyproject.toml, .gitignore stubs +├── Doc/ +│ ├── en/ ← English documentation (default) +│ │ ├── Tmux.md, zsh.md, tools.md, secrets.md +│ │ ├── emacs.md, htop.md, neofetch.md, yazi.md +│ ├── ja/ ← Japanese documentation +│ │ └── (same files as en/) +│ └── zh/ ← Simplified Chinese documentation +│ └── (same files as en/) +└── tmux-mem-cpu-load/ ← git submodule / local clone +``` + +## Running the Install Script (original, CI-tested) + +```bash +chmod +x install_and_configure.sh +./install_and_configure.sh +``` + +## Running bootstrap.sh (new modular system) + +```bash +bash bootstrap.sh # interactive menu +bash bootstrap.sh --all # install everything +bash bootstrap.sh --module shell # single module +bash bootstrap.sh --non-interactive # defaults (core+shell+dev) +bash bootstrap.sh --list # list modules +``` + +The bootstrap system: +1. Sources all `modules/*.sh` files +2. Shows an interactive feature selection menu +3. Calls the appropriate `install_()` function for each selected block +4. Calls `setup_zshrc_sourcing()` to append the `.zshrc.d` sourcing block to `~/.zshrc` + +## CI / Linting + +Three GitHub Actions workflows run on push/PR to `main`: +- **Linux**: runs `install_and_configure.sh` on `ubuntu-latest` +- **MacOS**: runs `install_and_configure.sh` on `macos-latest` +- **ShellCheck**: lints all shell scripts (`.zshrc` is excluded) + +To lint locally: +```bash +shellcheck install_and_configure.sh +shellcheck bootstrap.sh uninstall.sh modules/*.sh +``` + +## Key Configuration Details + +### Tmux (`dotfiles/.tmux.conf`) +- Prefix key is `Ctrl-t` (not the default `Ctrl-b`) +- Status bar displays memory/CPU via `tmux-mem-cpu-load` +- Custom pane splits: `prefix+2` = vertical, `prefix+3` = horizontal (both preserve current path) + +### Zsh (`dotfiles/.zshrc`) +- `ls` is aliased to `lsd` +- `yy` function wraps yazi to cd to the directory yazi exits in +- History: 1,000,000 entries, shared across sessions, deduplication enabled +- Modular sourcing block at the end loads `~/.zshrc.d/*.zsh` and `~/.zshrc.local` + +### .zshrc.d pattern +All per-tool zsh configuration lives in `dotfiles/.zshrc.d/*.zsh`. Each file: +- Guards its `eval` call with `command -v ` so it's a no-op if the tool is not installed +- Is deployed to `~/.zshrc.d/` by the corresponding module's `install_*()` function +- Is sourced automatically by the block appended to `~/.zshrc` + +### Secrets +Machine-specific config and secrets go in `~/.zshrc.local` (never committed). +Template: `dotfiles/.zshrc.local.example` + +### Adding a New Tool +1. Add installation logic to `modules/dev.sh` or a new `modules/.sh` +2. Create `dotfiles/.zshrc.d/.zsh` with guarded `eval`/aliases +3. Register in `bootstrap.sh` FEATURE_NAMES/FEATURE_LABELS arrays +4. Add a `deploy_zshrc_d ".zsh"` call in the module's deploy function +5. Add documentation to `Doc/en/tools.md`, `Doc/ja/tools.md`, `Doc/zh/tools.md` +6. For a core tool: also add `check_and_install "toolname"` to `install_and_configure.sh` diff --git a/Doc/emacs.md b/Doc/emacs.md deleted file mode 100644 index 99cf1d8..0000000 --- a/Doc/emacs.md +++ /dev/null @@ -1 +0,0 @@ -# emacs diff --git a/Doc/en/Tmux.md b/Doc/en/Tmux.md new file mode 100644 index 0000000..4bebe07 --- /dev/null +++ b/Doc/en/Tmux.md @@ -0,0 +1,34 @@ +# Tmux + +## Key Bindings + +| Action | Key Binding | Description | +|--------|-------------|-------------| +| New session | `tmux` | Start a new tmux session | +| Attach to session | `tmux attach-session -t ` | Attach to an existing tmux session | +| List sessions | `tmux list-sessions` | Show all current sessions | +| Detach from session | `Ctrl-t` + d | Detach from the current session | +| Switch session | `tmux switch-client -n` | Switch to the next session | +| Kill session | `tmux kill-session -t ` | Terminate the specified session | +| New window | `Ctrl-t` + c | Create a new window | +| List windows | `Ctrl-t` + w | Show windows in the session | +| Rename window | `Ctrl-t` + , | Rename the current window | +| Kill window | `Ctrl-t` + & | Close the current window | +| Split horizontally | `Ctrl-t` + % | Split the current pane horizontally | +| Split vertically | `Ctrl-t` + " | Split the current pane vertically | +| List panes | `Ctrl-t` + q | Show pane numbers in the current window | +| Switch pane | `Ctrl-t` + arrow keys | Move to the adjacent pane | +| Join pane | `Ctrl-t` + : → `join-pane -s ` | Join the specified pane into the current one | +| Resize pane | `Ctrl-t` + : → `resize-pane -D 5` | Resize the current pane downward by 5 units | +| Command mode | `Ctrl-t` + : | Enter command input mode | +| Help | `Ctrl-t` + ? | Show tmux help | +| Zoom pane | `Ctrl-t` + 1 | Toggle zoom for the current pane | +| Split vertically (cwd) | `Ctrl-t` + 2 | Split vertically, preserving current path | +| Split horizontally (cwd) | `Ctrl-t` + 3 | Split horizontally, preserving current path | +| Resize left | `Ctrl-t` + C-h | Resize pane left by 5 units | +| Resize right | `Ctrl-t` + C-l | Resize pane right by 5 units | +| Resize down | `Ctrl-t` + C-j | Resize pane down by 5 units | +| Resize up | `Ctrl-t` + C-k | Resize pane up by 5 units | +| Swap pane up | `Ctrl-t` + s | Swap the current pane with the one above | +| Kill pane | `Ctrl-t` + k | Close the current pane | +| Show all panes | `Ctrl-t` + i | Temporarily show all panes | diff --git a/Doc/en/emacs.md b/Doc/en/emacs.md new file mode 100644 index 0000000..b9d0a30 --- /dev/null +++ b/Doc/en/emacs.md @@ -0,0 +1,63 @@ +# emacs Configuration + +Summary of `dotfiles/.emacs.el` settings. +Installed to: `~/.emacs.el` + +--- + +## Package Setup + +MELPA and Marmalade are added as package archives and `package-initialize` is called. + +```elisp +(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) +(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) +``` + +--- + +## Key Binding Customization + +| Key | Action | +|-----|--------| +| `Ctrl-Z` | Undo (overrides the default `suspend-frame`) | + +--- + +## Auto-complete + +Uses `auto-complete-config`. + +- `TAB` triggers completion +- Use `Ctrl-N` / `Ctrl-P` to navigate the completion menu +- Fuzzy matching enabled +- Enabled modes: `text-mode`, `fundamental-mode`, `org-mode`, `yatex-mode` + +--- + +## Python Completion (jedi) + +`jedi.el` provides Python code completion. + +- Auto-triggers on `.` (dot) with `jedi:complete-on-dot` +- `` unbound from jedi to use for window navigation +- Completion sources: filenames + jedi direct (word completion from same-mode buffers removed) + +--- + +## Display Settings + +| Setting | Effect | +|---------|--------| +| `show-paren-mode` | Highlight matching parentheses | +| `global-linum-mode` | Show line numbers in all buffers (3-digit width) | + +--- + +## Load Path + +```elisp +(setq load-path (cons "~/.emacs.d/elisp" load-path)) +``` + +Place local Emacs Lisp files in `~/.emacs.d/elisp/`. diff --git a/Doc/en/htop.md b/Doc/en/htop.md new file mode 100644 index 0000000..f5f65e8 --- /dev/null +++ b/Doc/en/htop.md @@ -0,0 +1,84 @@ +# htop + +Interactive process viewer. A feature-rich alternative to `top`. + +--- + +## Launch + +```bash +htop +``` + +--- + +## Key Bindings + +### Navigation + +| Key | Action | +|-----|--------| +| `↑` / `↓` | Select process | +| `PgUp` / `PgDn` | Page up/down | +| `Home` / `End` | Jump to first/last | + +### Sorting + +| Key | Action | +|-----|--------| +| `P` | Sort by CPU usage | +| `M` | Sort by memory usage | +| `T` | Sort by run time | +| `F6` or `>` | Choose sort column | +| `I` | Invert sort order | + +### Filter & Search + +| Key | Action | +|-----|--------| +| `F3` or `/` | Search by process name | +| `F4` or `\` | Filter (narrow down) | +| `F5` | Toggle tree view | + +### Process Management + +| Key | Action | +|-----|--------| +| `F9` or `k` | Send signal (kill) | +| `F7` or `]` | Lower nice value (higher priority) | +| `F8` or `[` | Raise nice value (lower priority) | +| `Space` | Tag process (multi-select) | +| `U` | Untag all | + +### View Toggles + +| Key | Action | +|-----|--------| +| `F2` | Settings screen | +| `F1` or `h` | Help | +| `t` | Toggle tree view | +| `H` | Show/hide user threads | +| `K` | Show/hide kernel threads | + +### Other + +| Key | Action | +|-----|--------| +| `F10` or `q` | Quit | +| `u` | Show processes for a specific user | +| `a` | Set CPU affinity for a process | + +--- + +## Configuration File + +Settings are saved to `~/.config/htop/htoprc` (configurable via `F2`). + +--- + +## Reading the Display + +Top-section meters: +- **CPU bars** — Per-core usage (color-coded: `user` / `system` / `nice` / `io-wait`) +- **Mem / Swp bars** — Memory and swap usage +- **Tasks / Load / Uptime** — Process count, load average, system uptime diff --git a/Doc/en/neofetch.md b/Doc/en/neofetch.md new file mode 100644 index 0000000..14475e2 --- /dev/null +++ b/Doc/en/neofetch.md @@ -0,0 +1,66 @@ +# neofetch + +Displays system information alongside ASCII art. + +--- + +## Usage + +```bash +neofetch +``` + +Run when opening a new terminal or entering a new environment to quickly check +OS, kernel, CPU, memory, and other system details. + +--- + +## Displayed Information + +| Field | Content | +|-------|---------| +| OS | Distribution name and version | +| Host | Hostname and machine model | +| Kernel | Kernel version | +| Uptime | System uptime | +| Packages | Number of installed packages | +| Shell | Current shell and version | +| Resolution | Screen resolution (if desktop environment is available) | +| DE / WM | Desktop environment / window manager | +| Terminal | Terminal emulator in use | +| CPU | Processor name and core count | +| GPU | Graphics card (if detectable) | +| Memory | Used / total memory | + +--- + +## Common Options + +```bash +neofetch --off # Show info only, no ASCII art +neofetch --ascii_distro ubuntu # Use a different distro's ASCII art +neofetch --config none # Ignore config file +``` + +--- + +## Configuration File + +Customize displayed fields, colors, and ASCII art in `~/.config/neofetch/config.conf`. + +```bash +# Generate config file (first time) +neofetch --config ~/.config/neofetch/config.conf +``` + +Key settings: +- Comment out `info` lines to hide specific fields +- Change `image_backend` to use images instead of ASCII art (requires kitty / iTerm2 / WezTerm) +- Customize `colors` for the color scheme + +--- + +## WSL Note + +On WSL2, GPU info and screen resolution may not be detected correctly. +Using `neofetch --off` gives stable output for the info section only. diff --git a/Doc/en/secrets.md b/Doc/en/secrets.md new file mode 100644 index 0000000..21440c0 --- /dev/null +++ b/Doc/en/secrets.md @@ -0,0 +1,79 @@ +# Secrets Management + +**Never commit API keys, tokens, or other secrets to a git repository.** +This document explains how to manage secrets safely with this dotfiles setup. + +--- + +## Using ~/.zshrc.local (Recommended) + +`.zshrc.local` is not tracked by git and is automatically sourced from `~/.zshrc`. + +```bash +# Copy the template +cp dotfiles/.zshrc.local.example ~/.zshrc.local + +# Edit with your editor +$EDITOR ~/.zshrc.local +``` + +Example `.zshrc.local` content: + +```zsh +export ANTHROPIC_API_KEY="sk-ant-..." +export GITHUB_TOKEN="ghp_..." +export AWS_DEFAULT_REGION="ap-northeast-1" +``` + +`*.local` is listed in `.gitignore`, so it won't be accidentally committed. + +--- + +## Using direnv (Per-project) + +For per-project credentials, `direnv` is convenient. + +```bash +# In your project directory +echo 'export DATABASE_URL="postgresql://localhost/myapp_dev"' > .envrc +direnv allow +``` + +It is recommended to add `.envrc` to your project's `.gitignore`: + +``` +.envrc +.envrc.local +``` + +--- + +## Secret Management Tools (Advanced) + +For more robust management: + +| Tool | Use Case | +|------|----------| +| [1Password CLI](https://developer.1password.com/docs/cli/) | Inject secrets from 1Password | +| [Bitwarden CLI](https://bitwarden.com/help/cli/) | Inject secrets from Bitwarden | +| [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) | Cloud secret management | +| [HashiCorp Vault](https://www.vaultproject.io/) | Enterprise secret management | + +--- + +## If You Accidentally Commit a Secret + +1. **Immediately revoke and rotate the secret** +2. Remove the secret from git history: + ```bash + # Using BFG Repo Cleaner + bfg --replace-text secrets.txt + git reflog expire --expire=now --all + git gc --prune=now --aggressive + git push --force + ``` +3. Notify your team + +> [!CAUTION] +> Once pushed, a secret may have been exposed even after "deletion". +> Always rotate your secrets. diff --git a/Doc/en/tools.md b/Doc/en/tools.md new file mode 100644 index 0000000..58ce93c --- /dev/null +++ b/Doc/en/tools.md @@ -0,0 +1,180 @@ +# Tools Guide + +Configuration and usage guide for tools installed by the Shell and Dev blocks of `bootstrap.sh`. + +--- + +## starship + +**Config file:** `~/.config/starship.toml` (deployed from `config/starship.toml`) + +Two-line prompt. Displays current directory, git branch, language version, and command duration. +Node.js, Python, Rust, etc. are only shown when relevant files exist in the directory. + +Customization example: + +```toml +# starship.toml +[directory] +truncation_length = 3 + +[cmd_duration] +min_time = 5000 # Only show commands taking more than 5 seconds +``` + +--- + +## fzf + +**Key bindings:** + +| Key | Action | +|-----|--------| +| `Ctrl-T` | Search files and insert into command line | +| `Ctrl-R` | Search command history | +| `Alt-C` | Change directory interactively | + +**Custom functions (fzf.zsh):** + +```zsh +fcd # Fuzzy change directory +fkill # Fuzzy process kill +``` + +When ripgrep is available, file search automatically respects `.gitignore`. + +--- + +## zoxide + +Smart `cd` replacement. Learns directories you frequently navigate to. + +```zsh +z proj # Jump to a frequently used directory containing "proj" +z do sh # Jump to directory matching both "do" and "sh" +zi # Interactive selection with fzf +``` + +--- + +## atuin + +SQLite-based shell history. + +**Key bindings:** + +| Key | Action | +|-----|--------| +| `Ctrl-R` | Fuzzy history search | +| `↑` | Normal history (up arrow not overridden) | + +**Config file:** `~/.config/atuin/config.toml` (deployed from `config/atuin/config.toml`) + +--- + +## direnv + +Auto-load environment variables per directory. + +```bash +# Create .envrc in your project +echo 'export API_KEY="dev-key"' > .envrc +direnv allow + +# Variables are automatically cleared when you leave the directory +``` + +--- + +## gh (GitHub CLI) + +```bash +gh pr list # List pull requests +gh pr create --fill # Create PR (auto-fill from commit messages) +gh pr checkout 123 # Check out PR locally +gh issue create -t "Bug" -b "..." # Create an issue +gh repo clone user/repo # Clone a repository +``` + +--- + +## ripgrep (rg) + +Fast grep alternative. Respects `.gitignore` automatically. + +```bash +rg "TODO" # Recursive search in current directory +rg -t py "def main" # Search Python files only +rg -l "import react" # Show filenames only +rg --hidden "secret" # Include hidden files +``` + +--- + +## bat + +`cat` alternative with syntax highlighting. + +```bash +bat file.py # Syntax-highlighted output +bat --plain file.py # No line numbers +bat -A file.py # Show non-printable characters +``` + +--- + +## delta + +Syntax-highlighted git diff pager. Automatically configured by `_setup_git_config`. + +```bash +git diff # delta is used automatically +git log -p # Commit diffs also use delta +``` + +--- + +## lazygit + +TUI git client. + +```bash +lazygit # or: lg +``` + +**Key bindings inside lazygit:** + +| Key | Action | +|-----|--------| +| `s` | Stage file | +| `c` | Commit | +| `p` | Push | +| `P` | Pull | +| `?` | Help | + +--- + +## Git aliases (commit.zsh) + +| Alias | Command | +|-------|---------| +| `gs` | `git status -sb` | +| `gd` | `git diff` | +| `gds` | `git diff --staged` | +| `ga` | `git add` | +| `gc` | `git commit` | +| `gcm` | `git commit -m` | +| `gco` | `git checkout` | +| `gcb` | `git checkout -b` | +| `gp` | `git push` | +| `gpf` | `git push --force-with-lease` | +| `gpl` | `git pull --rebase` | +| `glog` | One-line git log (20 entries) | +| `glogg` | Graph git log (30 entries) | + +**Conventional commits:** + +```bash +gcommit feat "add dark mode" # feat: add dark mode +gcommit fix "login crash" auth # fix(auth): login crash +``` diff --git a/Doc/en/yazi.md b/Doc/en/yazi.md new file mode 100644 index 0000000..ffbc121 --- /dev/null +++ b/Doc/en/yazi.md @@ -0,0 +1,98 @@ +# Yazi + +Terminal file manager. Written in Rust; asynchronous and fast. + +--- + +## Launch + +```bash +yy # Launch yazi; automatically cd to exit directory +yazi # Direct launch (no cd after exit) +``` + +`yy` is a function defined in `.zshrc` that carries yazi's exit directory back to the shell. +If already inside yazi (`YAZI_LEVEL` is set), it runs `exit` to leave the inner shell. + +--- + +## Key Bindings + +### Navigation + +| Key | Action | +|-----|--------| +| `h` or `←` | Go to parent directory | +| `l` or `→` / `Enter` | Open selected item (enter directory) | +| `j` or `↓` | Move down | +| `k` or `↑` | Move up | +| `gg` | Jump to top | +| `G` | Jump to bottom | +| `H` | Jump to top of screen | +| `M` | Jump to middle of screen | +| `L` | Jump to bottom of screen | + +### File Operations + +| Key | Action | +|-----|--------| +| `Space` | Tag file (multi-select) | +| `v` | Toggle visual mode (select all, etc.) | +| `y` | Yank (copy) | +| `x` | Cut | +| `p` | Paste | +| `d` | Move to trash | +| `D` | Permanently delete (with confirmation) | +| `a` | Create new file / directory (trailing `/` for directory) | +| `r` | Rename | + +### View & Search + +| Key | Action | +|-----|--------| +| `.` | Toggle hidden files | +| `/` | Filter by filename | +| `f` | Fuzzy search (fzf-like) | +| `s` | Change sort order | +| `z` | Jump to directory with zoxide | + +### Tabs + +| Key | Action | +|-----|--------| +| `t` | Open new tab | +| `1` – `9` | Switch to tab | +| `[` / `]` | Previous / next tab | + +### Other + +| Key | Action | +|-----|--------| +| `q` | Quit | +| `~` | Go to home directory | +| `-` | Go back to previous directory | +| `o` | Open with default application | +| `e` | Open with editor | +| `i` | Full-screen preview | +| `?` | Show all key bindings | + +--- + +## Configuration Files + +Place configuration in `~/.config/yazi/` (defaults are used if not present). + +``` +~/.config/yazi/ +├── yazi.toml # General settings (sorting, etc.) +├── keymap.toml # Key binding customization +├── theme.toml # Theme and colors +└── plugins/ # Plugins +``` + +--- + +## Preview Support + +Asynchronously previews text, images (on supported terminals), PDFs, audio, and video thumbnails. +Image preview requires kitty, iTerm2, WezTerm, or another compatible terminal. diff --git a/Doc/en/zsh.md b/Doc/en/zsh.md new file mode 100644 index 0000000..750939c --- /dev/null +++ b/Doc/en/zsh.md @@ -0,0 +1,117 @@ +# zsh Configuration + +Summary of `dotfiles/.zshrc` settings. + +--- + +## Aliases + +| Alias | Expansion | Description | +|-------|-----------|-------------| +| `ls` | `lsd` | Directory listing with icons | +| `l`, `ll` | `ls -l` | Long format | +| `la` | `ls -a` | Include hidden files | +| `lla` | `ls -la` | Long format with hidden files | +| `lt` | `ls --tree` | Tree view | +| `llt` | `ll --tree` | Long format tree view | +| `rm` | `rm -i` | Confirm before deleting | +| `cp` | `cp -i` | Confirm before overwriting | +| `mv` | `mv -i` | Confirm before overwriting | +| `mkdir` | `mkdir -p` | Create intermediate directories | +| `sudo` | `sudo ` | Enable aliases after sudo | + +**Global aliases (expand even after pipe):** + +| Alias | Expansion | +|-------|-----------| +| `L` | `\| less` | +| `G` | `\| grep` | + +--- + +## Key Bindings + +Emacs-style key bindings (`bindkey -e`) are enabled by default. + +| Key | Action | +|-----|--------| +| `Ctrl-R` | Incremental history search with wildcard support | +| `Ctrl-A` | Move to beginning of line | +| `Ctrl-E` | Move to end of line | +| `Ctrl-W` | Delete one word backward (splits on `/=;@:{},|`) | +| `Ctrl-U` | Delete everything before cursor | +| `Ctrl-K` | Delete everything after cursor | + +--- + +## History Settings + +| Setting | Value | +|---------|-------| +| Size (`HISTSIZE` / `SAVEHIST`) | 1,000,000 | +| File | `~/.zsh_history` | +| Share across sessions | `share_history` | +| Deduplication | `hist_ignore_all_dups` / `hist_save_nodups` | +| Skip space-prefixed commands | `hist_ignore_space` | +| Strip extra whitespace | `hist_reduce_blanks` | + +--- + +## Key Options + +| Option | Effect | +|--------|--------| +| `auto_cd` | `cd` by typing a directory name alone | +| `auto_pushd` | Push to directory stack on every `cd` | +| `pushd_ignore_dups` | No duplicate entries in directory stack | +| `magic_equal_subst` | Path completion after `=` | +| `interactive_comments` | Treat `#` as comment in interactive shell | +| `no_beep` | Disable bell | +| `extended_glob` | Advanced wildcards (`**`, `^`, `~`) | +| `auto_menu` | Show completion menu when multiple candidates exist | + +--- + +## Completion + +- Lowercase input matches uppercase (`m:{a-z}={A-Z}`) +- Skip current directory after `../` +- Complete command names after `sudo` +- Complete process names for `ps` + +--- + +## Functions + +### `chpwd` — auto ls after cd + +```zsh +cd ~/project # → automatically runs lsd +``` + +### `yy` — directory-aware yazi launcher + +```zsh +yy # Launch yazi; cd to its exit directory afterward +``` + +If already inside yazi (`YAZI_LEVEL` is set), `exit` leaves the inner shell. + +--- + +## Modular Loading + +Block appended to the end of `.zshrc`: + +```zsh +# Auto-load ~/.zshrc.d/*.zsh (placed by bootstrap.sh) +for _f in "$HOME/.zshrc.d"/*.zsh; do + [ -r "$_f" ] && . "$_f" +done + +# Machine-specific / secret config (never committed) +[ -f "$HOME/.zshrc.local" ] && . "$HOME/.zshrc.local" +``` + +Each `.zshrc.d/*.zsh` file has a `command -v ` guard so it is safely +skipped when the tool is not installed. diff --git a/Doc/htop.md b/Doc/htop.md deleted file mode 100644 index 85a8816..0000000 --- a/Doc/htop.md +++ /dev/null @@ -1 +0,0 @@ -# htop diff --git a/Doc/Tmux.md b/Doc/ja/Tmux.md similarity index 100% rename from Doc/Tmux.md rename to Doc/ja/Tmux.md diff --git a/Doc/ja/emacs.md b/Doc/ja/emacs.md new file mode 100644 index 0000000..05eb280 --- /dev/null +++ b/Doc/ja/emacs.md @@ -0,0 +1,63 @@ +# emacs 設定 + +`dotfiles/.emacs.el` の設定内容まとめ。 +インストール先: `~/.emacs.el` + +--- + +## パッケージ設定 + +MELPA と Marmalade を追加して `package-initialize` を実行。 + +```elisp +(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) +(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) +``` + +--- + +## キーバインドカスタマイズ + +| キー | 動作 | +|------|------| +| `Ctrl-Z` | undo(デフォルトの `suspend-frame` を上書き) | + +--- + +## 自動補完 (auto-complete) + +`auto-complete-config` を使用。 + +- `TAB` で補完トリガー +- 補完メニュー表示中は `Ctrl-N` / `Ctrl-P` で候補選択 +- 曖昧マッチ(fuzzy)有効 +- 有効モード: `text-mode`, `fundamental-mode`, `org-mode`, `yatex-mode` + +--- + +## Python 補完 (jedi) + +`jedi.el` で Python のコード補完を提供。 + +- `.` 入力で自動補完トリガー(`jedi:complete-on-dot`) +- `` は jedi から外し、ウィンドウ移動に使用 +- 補完ソース: ファイル名 + jedi ダイレクト(同一モードの単語補完は除外) + +--- + +## 表示設定 + +| 設定 | 効果 | +|------|------| +| `show-paren-mode` | 対応する括弧をハイライト | +| `global-linum-mode` | 全バッファで行番号を表示(3桁幅) | + +--- + +## ロードパス + +```elisp +(setq load-path (cons "~/.emacs.d/elisp" load-path)) +``` + +`~/.emacs.d/elisp/` にローカルの Emacs Lisp ファイルを置けます。 diff --git a/Doc/ja/htop.md b/Doc/ja/htop.md new file mode 100644 index 0000000..310519e --- /dev/null +++ b/Doc/ja/htop.md @@ -0,0 +1,84 @@ +# htop + +インタラクティブなプロセスビューア。`top` の高機能代替。 + +--- + +## 起動 + +```bash +htop +``` + +--- + +## 主要キーバインド + +### ナビゲーション + +| キー | 動作 | +|------|------| +| `↑` / `↓` | プロセス選択 | +| `↑PgUp` / `PgDn` | ページ送り | +| `Home` / `End` | 先頭 / 末尾へ | + +### ソート + +| キー | 動作 | +|------|------| +| `P` | CPU 使用率でソート | +| `M` | メモリ使用量でソート | +| `T` | 実行時間でソート | +| `F6` または `>` | ソートカラムを選択 | +| `I` | ソート順を反転 | + +### フィルタ・検索 + +| キー | 動作 | +|------|------| +| `F3` または `/` | プロセス名で検索 | +| `F4` または `\` | フィルタ(絞り込み) | +| `F5` | ツリー表示の切り替え | + +### プロセス操作 + +| キー | 動作 | +|------|------| +| `F9` または `k` | シグナル送信(kill) | +| `F7` または `]` | nice 値を下げる(優先度上昇) | +| `F8` または `[` | nice 値を上げる(優先度低下) | +| `Space` | プロセスをタグ付け(複数選択) | +| `U` | 全タグ解除 | + +### 表示切り替え + +| キー | 動作 | +|------|------| +| `F2` | 設定画面 | +| `F1` または `h` | ヘルプ | +| `t` | ツリー表示切り替え | +| `H` | ユーザースレッドの表示/非表示 | +| `K` | カーネルスレッドの表示/非表示 | + +### その他 + +| キー | 動作 | +|------|------| +| `F10` または `q` | 終了 | +| `u` | 特定ユーザーのプロセスのみ表示 | +| `a` | プロセスの CPU コアを固定(アフィニティ) | + +--- + +## 設定ファイル + +`~/.config/htop/htoprc` に設定が保存されます(GUI 設定は `F2` から)。 + +--- + +## 見方 + +画面上部のメーター: +- **CPU バー** — コアごとの使用率(色分け:`user` / `system` / `nice` / `io-wait`) +- **Mem / Swp バー** — メモリ・スワップ使用量 +- **Tasks / Load / Uptime** — プロセス数、ロードアベレージ、稼働時間 diff --git a/Doc/ja/neofetch.md b/Doc/ja/neofetch.md new file mode 100644 index 0000000..585bd60 --- /dev/null +++ b/Doc/ja/neofetch.md @@ -0,0 +1,66 @@ +# neofetch + +システム情報をアスキーアートと共に表示するツール。 + +--- + +## 使い方 + +```bash +neofetch +``` + +ターミナルを開いたときや新しい環境に入ったときに実行すると、 +OS・カーネル・CPU・メモリなどの情報を素早く確認できます。 + +--- + +## 表示される情報 + +| 項目 | 内容 | +|------|------| +| OS | ディストリビューション名とバージョン | +| Host | ホスト名・マシンモデル | +| Kernel | カーネルバージョン | +| Uptime | システム稼働時間 | +| Packages | インストール済みパッケージ数 | +| Shell | 使用中のシェルとバージョン | +| Resolution | 画面解像度(デスクトップ環境がある場合) | +| DE / WM | デスクトップ環境 / ウィンドウマネージャ | +| Terminal | 使用中のターミナルエミュレータ | +| CPU | プロセッサ名とコア数 | +| GPU | グラフィックカード(検出できる場合) | +| Memory | メモリ使用量 / 総量 | + +--- + +## 主なオプション + +```bash +neofetch --off # アスキーアートなしで情報のみ表示 +neofetch --ascii_distro ubuntu # 別のディストリのアスキーアートを使用 +neofetch --config none # 設定ファイルを無視して実行 +``` + +--- + +## 設定ファイル + +`~/.config/neofetch/config.conf` で表示項目・色・アスキーアートをカスタマイズできます。 + +```bash +# 設定ファイルを生成(初回) +neofetch --config ~/.config/neofetch/config.conf +``` + +主な設定項目: +- `info` 行のコメントアウトで表示項目を非表示にする +- `image_backend` でアスキーアートを画像に変更(kitty / iterm2 など対応ターミナルのみ) +- `colors` で配色をカスタマイズ + +--- + +## WSL での注意 + +WSL2 上では GPU 情報や解像度が正しく取得できない場合があります。 +`neofetch --off` で情報部分のみ確認するのが安定しています。 diff --git a/Doc/ja/secrets.md b/Doc/ja/secrets.md new file mode 100644 index 0000000..5f1bcad --- /dev/null +++ b/Doc/ja/secrets.md @@ -0,0 +1,79 @@ +# 秘密情報の管理 + +API キーやトークンなどの秘密情報は **絶対に git リポジトリにコミットしないでください**。 +このドキュメントでは、dotfiles リポジトリで秘密情報を安全に管理する方法を説明します。 + +--- + +## ~/.zshrc.local を使う(推奨) + +`.zshrc.local` は git の管理外ファイルで、`~/.zshrc` から自動的に読み込まれます。 + +```bash +# テンプレートをコピー +cp dotfiles/.zshrc.local.example ~/.zshrc.local + +# エディタで編集 +$EDITOR ~/.zshrc.local +``` + +`.zshrc.local` の内容例: + +```zsh +export ANTHROPIC_API_KEY="sk-ant-..." +export GITHUB_TOKEN="ghp_..." +export AWS_DEFAULT_REGION="ap-northeast-1" +``` + +`.gitignore` に `*.local` が追加されているため、誤ってコミットされません。 + +--- + +## direnv を使う(プロジェクト単位) + +プロジェクトごとに異なる認証情報を使う場合は `direnv` が便利です。 + +```bash +# プロジェクトディレクトリで +echo 'export DATABASE_URL="postgresql://localhost/myapp_dev"' > .envrc +direnv allow +``` + +`.envrc` は `.gitignore` に追加しておくことを推奨します: + +``` +.envrc +.envrc.local +``` + +--- + +## シークレット管理ツール(上級者向け) + +より堅牢な管理が必要な場合: + +| ツール | 用途 | +|-------|------| +| [1Password CLI](https://developer.1password.com/docs/cli/) | 1Password からシークレットを注入 | +| [Bitwarden CLI](https://bitwarden.com/help/cli/) | Bitwarden からシークレットを注入 | +| [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) | クラウドシークレット管理 | +| [HashiCorp Vault](https://www.vaultproject.io/) | エンタープライズ向けシークレット管理 | + +--- + +## 誤ってコミットしてしまった場合 + +1. **すぐにシークレットを無効化・ローテーション**する +2. git 履歴からシークレットを削除する: + ```bash + # BFG Repo Cleaner を使用 + bfg --replace-text secrets.txt + git reflog expire --expire=now --all + git gc --prune=now --aggressive + git push --force + ``` +3. チームメンバーに通知する + +> [!CAUTION] +> 一度 push したシークレットは「削除済み」でも外部に漏洩した可能性があります。 +> 必ずシークレットをローテーションしてください。 diff --git a/Doc/ja/tools.md b/Doc/ja/tools.md new file mode 100644 index 0000000..695a8ed --- /dev/null +++ b/Doc/ja/tools.md @@ -0,0 +1,180 @@ +# ツール詳細ガイド + +`bootstrap.sh` の Shell / Dev ブロックでインストールされるツールの設定と使い方。 + +--- + +## starship + +**設定ファイル:** `~/.config/starship.toml`(`config/starship.toml` から配置) + +2行プロンプト。カレントディレクトリ・git ブランチ・言語バージョン・コマンド実行時間を表示。 +Node.js・Python・Rust などは関連ファイルが存在する場合のみ表示。 + +カスタマイズ例: + +```toml +# starship.toml +[directory] +truncation_length = 3 + +[cmd_duration] +min_time = 5000 # 5秒以上のコマンドのみ表示 +``` + +--- + +## fzf + +**キーバインド:** + +| キー | 動作 | +|------|------| +| `Ctrl-T` | ファイル検索して挿入 | +| `Ctrl-R` | ヒストリ検索 | +| `Alt-C` | ディレクトリに移動 | + +**カスタム関数(fzf.zsh):** + +```zsh +fcd # ファジーでディレクトリ移動 +fkill # ファジーでプロセス kill +``` + +ripgrep がある場合は `.gitignore` を自動的に尊重してファイル検索します。 + +--- + +## zoxide + +`cd` の賢い代替。頻繁に移動するディレクトリを学習します。 + +```zsh +z proj # "proj" を含むよく使うディレクトリへ移動 +z do sh # "do" と "sh" を含むディレクトリへ +zi # fzf でインタラクティブ選択 +``` + +--- + +## atuin + +SQLite ベースのシェルヒストリ。 + +**キーバインド:** + +| キー | 動作 | +|------|------| +| `Ctrl-R` | ファジーヒストリ検索 | +| `↑` | 通常のヒストリ(無効化していないため従来通り) | + +**設定ファイル:** `~/.config/atuin/config.toml`(`config/atuin/config.toml` から配置) + +--- + +## direnv + +ディレクトリごとの環境変数自動ロード。 + +```bash +# プロジェクトで .envrc を作成 +echo 'export API_KEY="dev-key"' > .envrc +direnv allow + +# ディレクトリを出ると自動的に環境変数がクリアされる +``` + +--- + +## gh (GitHub CLI) + +```bash +gh pr list # PR 一覧 +gh pr create --fill # PR 作成(コミットメッセージから自動) +gh pr checkout 123 # PR をローカルにチェックアウト +gh issue create -t "Bug" -b "..." # Issue 作成 +gh repo clone user/repo # リポジトリのクローン +``` + +--- + +## ripgrep (rg) + +高速 grep 代替。`.gitignore` を自動尊重。 + +```bash +rg "TODO" # カレントディレクトリを再帰検索 +rg -t py "def main" # Python ファイルのみ +rg -l "import react" # ファイル名のみ表示 +rg --hidden "secret" # 隠しファイルも検索 +``` + +--- + +## bat + +シンタックスハイライト付き `cat`。 + +```bash +bat file.py # シンタックスハイライト表示 +bat --plain file.py # 行番号なし +bat -A file.py # 制御文字を表示 +``` + +--- + +## delta + +シンタックスハイライト付き git diff ページャ。`_setup_git_config` で自動設定されます。 + +```bash +git diff # delta が自動的に使われる +git log -p # コミット差分も delta で表示 +``` + +--- + +## lazygit + +git の TUI クライアント。 + +```bash +lazygit # または lg +``` + +**主要キーバインド(lazygit 内):** + +| キー | 動作 | +|------|------| +| `s` | ステージング | +| `c` | コミット | +| `p` | push | +| `P` | pull | +| `?` | ヘルプ | + +--- + +## commit.zsh の git エイリアス + +| エイリアス | コマンド | +|-----------|---------| +| `gs` | `git status -sb` | +| `gd` | `git diff` | +| `gds` | `git diff --staged` | +| `ga` | `git add` | +| `gc` | `git commit` | +| `gcm` | `git commit -m` | +| `gco` | `git checkout` | +| `gcb` | `git checkout -b` | +| `gp` | `git push` | +| `gpf` | `git push --force-with-lease` | +| `gpl` | `git pull --rebase` | +| `glog` | ワンライン git log (20件) | +| `glogg` | グラフ付き git log (30件) | + +**コンベンショナルコミット:** + +```bash +gcommit feat "add dark mode" # feat: add dark mode +gcommit fix "login crash" auth # fix(auth): login crash +``` diff --git a/Doc/ja/yazi.md b/Doc/ja/yazi.md new file mode 100644 index 0000000..1bc6845 --- /dev/null +++ b/Doc/ja/yazi.md @@ -0,0 +1,99 @@ +# Yazi + +ターミナルファイルマネージャ。Rust 製で非同期・高速動作。 + +--- + +## 起動 + +```bash +yy # yazi を起動し、終了後そのディレクトリに自動で cd +yazi # 直接起動(終了後の cd なし) +``` + +`yy` は `.zshrc` に定義された関数で、yazi の終了ディレクトリをシェルに引き継ぎます。 +すでに yazi 内にいる場合(`YAZI_LEVEL` が設定済み)は `exit` で内側のシェルを抜けます。 + +--- + +## 基本キーバインド + +### ナビゲーション + +| キー | 動作 | +|------|------| +| `h` または `←` | 親ディレクトリへ | +| `l` または `→` / `Enter` | 選択項目を開く(ディレクトリに入る) | +| `j` または `↓` | 下へ移動 | +| `k` または `↑` | 上へ移動 | +| `gg` | 先頭へ | +| `G` | 末尾へ | +| `H` | 画面上部へ | +| `M` | 画面中央へ | +| `L` | 画面下部へ | + +### ファイル操作 + +| キー | 動作 | +|------|------| +| `Space` | ファイルをタグ付け(複数選択) | +| `v` | 選択モードを切り替え(全選択など) | +| `y` | コピー(ヤンク) | +| `x` | 切り取り | +| `p` | 貼り付け | +| `d` | ゴミ箱へ移動 | +| `D` | 完全削除(確認あり) | +| `a` | 新規ファイル / ディレクトリ作成(末尾 `/` でディレクトリ) | +| `r` | 名前変更 | + +### 表示・検索 + +| キー | 動作 | +|------|------| +| `.` | 隠しファイルの表示/非表示切り替え | +| `/` | ファイル名をフィルタリング検索 | +| `f` | ファジー検索(fzf 相当) | +| `s` | ソート方法を変更 | +| `z` | zoxide と連携してよく使うディレクトリへジャンプ | + +### タブ + +| キー | 動作 | +|------|------| +| `t` | 新しいタブを開く | +| `1` 〜 `9` | タブを切り替え | +| `[` / `]` | 前/次のタブへ | + +### その他 + +| キー | 動作 | +|------|------| +| `q` | 終了 | +| `~` | ホームディレクトリへ移動 | +| `-` | 直前のディレクトリへ戻る | +| `o` | デフォルトアプリで開く | +| `e` | エディタで開く | +| `i` | プレビューをフルスクリーン表示 | +| `?` | キーバインド一覧 | + +--- + +## 設定ファイル + +`~/.config/yazi/` に設定を置けます(未配置の場合はデフォルト設定を使用)。 + +``` +~/.config/yazi/ +├── yazi.toml # 全般設定(ソートなど) +├── keymap.toml # キーバインドカスタマイズ +├── theme.toml # テーマ・配色 +└── plugins/ # プラグイン +``` + +--- + +## プレビュー対応形式 + +テキスト・画像(対応ターミナル)・PDF・音声・動画のサムネイルなど、 +多様な形式のプレビューを非同期で表示します。 +画像プレビューには kitty / iTerm2 / WezTerm などのターミナルが必要です。 diff --git a/Doc/ja/zsh.md b/Doc/ja/zsh.md new file mode 100644 index 0000000..69331ae --- /dev/null +++ b/Doc/ja/zsh.md @@ -0,0 +1,117 @@ +# zsh 設定 + +`dotfiles/.zshrc` の設定内容まとめ。 + +--- + +## エイリアス + +| エイリアス | 展開 | 説明 | +|-----------|------|------| +| `ls` | `lsd` | アイコン付きディレクトリ一覧 | +| `l`, `ll` | `ls -l` | 詳細表示 | +| `la` | `ls -a` | 隠しファイルも表示 | +| `lla` | `ls -la` | 詳細+隠しファイル | +| `lt` | `ls --tree` | ツリー表示 | +| `llt` | `ll --tree` | 詳細ツリー表示 | +| `rm` | `rm -i` | 削除前に確認 | +| `cp` | `cp -i` | 上書き前に確認 | +| `mv` | `mv -i` | 上書き前に確認 | +| `mkdir` | `mkdir -p` | 中間ディレクトリも作成 | +| `sudo` | `sudo ` | sudo の後ろでもエイリアスを有効化 | + +**グローバルエイリアス(パイプ後でも展開される):** + +| エイリアス | 展開 | +|-----------|------| +| `L` | `\| less` | +| `G` | `\| grep` | + +--- + +## キーバインド + +emacs 風キーバインド(`bindkey -e`)が基本。 + +| キー | 動作 | +|------|------| +| `Ctrl-R` | ワイルドカード対応のインクリメンタルヒストリ検索 | +| `Ctrl-A` | 行頭へ移動 | +| `Ctrl-E` | 行末へ移動 | +| `Ctrl-W` | 単語区切り(`/ = ; @ : { } , |` 含む)で1単語削除 | +| `Ctrl-U` | カーソルより前を全削除 | +| `Ctrl-K` | カーソルより後を全削除 | + +--- + +## ヒストリ設定 + +| 設定 | 値 | +|------|-----| +| 保存件数 (`HISTSIZE` / `SAVEHIST`) | 1,000,000 | +| 保存ファイル | `~/.zsh_history` | +| セッション間共有 | `share_history` | +| 重複除去 | `hist_ignore_all_dups` / `hist_save_nodups` | +| スペース始まりは除外 | `hist_ignore_space` | +| 余分なスペース削除 | `hist_reduce_blanks` | + +--- + +## 主要オプション + +| オプション | 効果 | +|-----------|------| +| `auto_cd` | ディレクトリ名だけで `cd` | +| `auto_pushd` | `cd` のたびにディレクトリスタックに積む | +| `pushd_ignore_dups` | スタックの重複を除去 | +| `magic_equal_subst` | `=` の後もパス補完 | +| `interactive_comments` | `#` 以降をコメントとして扱う | +| `no_beep` | ビープ音を無効化 | +| `extended_glob` | 高機能ワイルドカード (`**`, `^`, `~`) | +| `auto_menu` | 補完候補が複数のとき一覧表示 | + +--- + +## 補完設定 + +- 小文字入力で大文字にもマッチ(`m:{a-z}={A-Z}`) +- `../` の後は現在ディレクトリを補完しない +- `sudo` の後もコマンド名を補完 +- `ps` のプロセス名を補完 + +--- + +## 関数 + +### `chpwd` — cd 後に自動 ls + +```zsh +cd ~/project # → 自動的に lsd で一覧表示 +``` + +### `yy` — yazi を使ったディレクトリ移動 + +```zsh +yy # yazi を起動し、終了後そのディレクトリに cd +``` + +すでに yazi 内にいる場合(`YAZI_LEVEL` が設定されている)は `exit` で抜けます。 + +--- + +## モジュール読み込み + +`.zshrc` 末尾に追加されるブロック: + +```zsh +# ~/.zshrc.d/*.zsh を自動読み込み(bootstrap.sh が配置) +for _f in "$HOME/.zshrc.d"/*.zsh; do + [ -r "$_f" ] && . "$_f" +done + +# マシン固有・秘密情報(git 管理外) +[ -f "$HOME/.zshrc.local" ] && . "$HOME/.zshrc.local" +``` + +各 `.zshrc.d/*.zsh` は `command -v ` ガードが付いており、 +ツールが未インストールでも安全に無視されます。 diff --git a/Doc/neofetch.md b/Doc/neofetch.md deleted file mode 100644 index f0cfc26..0000000 --- a/Doc/neofetch.md +++ /dev/null @@ -1 +0,0 @@ -# neofetch diff --git a/Doc/yazi.md b/Doc/yazi.md deleted file mode 100644 index a0113c3..0000000 --- a/Doc/yazi.md +++ /dev/null @@ -1,2 +0,0 @@ -# Yazi - diff --git a/Doc/zh/Tmux.md b/Doc/zh/Tmux.md new file mode 100644 index 0000000..b51188e --- /dev/null +++ b/Doc/zh/Tmux.md @@ -0,0 +1,34 @@ +# Tmux + +## 按键绑定 + +| 操作 | 快捷键 | 说明 | +|------|--------|------| +| 新建会话 | `tmux` | 启动一个新的 tmux 会话 | +| 连接会话 | `tmux attach-session -t <名称>` | 连接到已有的 tmux 会话 | +| 列出会话 | `tmux list-sessions` | 显示当前所有会话 | +| 分离会话 | `Ctrl-t` + d | 从当前会话分离 | +| 切换会话 | `tmux switch-client -n` | 切换到下一个会话 | +| 终止会话 | `tmux kill-session -t <名称>` | 终止指定会话 | +| 新建窗口 | `Ctrl-t` + c | 创建新窗口 | +| 列出窗口 | `Ctrl-t` + w | 显示会话中的窗口列表 | +| 重命名窗口 | `Ctrl-t` + , | 重命名当前窗口 | +| 关闭窗口 | `Ctrl-t` + & | 关闭当前窗口 | +| 水平分割面板 | `Ctrl-t` + % | 水平分割当前面板 | +| 垂直分割面板 | `Ctrl-t` + " | 垂直分割当前面板 | +| 列出面板 | `Ctrl-t` + q | 显示当前窗口中的面板编号 | +| 切换面板 | `Ctrl-t` + 方向键 | 切换到相邻面板 | +| 合并面板 | `Ctrl-t` + : → `join-pane -s ` | 将指定面板合并到当前面板 | +| 调整面板大小 | `Ctrl-t` + : → `resize-pane -D 5` | 向下调整当前面板大小 5 个单位 | +| 命令模式 | `Ctrl-t` + : | 进入命令输入模式 | +| 帮助 | `Ctrl-t` + ? | 显示 tmux 帮助 | +| 面板缩放 | `Ctrl-t` + 1 | 切换当前面板的缩放状态 | +| 垂直分割(保留路径) | `Ctrl-t` + 2 | 垂直分割,保留当前目录 | +| 水平分割(保留路径) | `Ctrl-t` + 3 | 水平分割,保留当前目录 | +| 向左调整 | `Ctrl-t` + C-h | 向左调整面板大小 5 个单位 | +| 向右调整 | `Ctrl-t` + C-l | 向右调整面板大小 5 个单位 | +| 向下调整 | `Ctrl-t` + C-j | 向下调整面板大小 5 个单位 | +| 向上调整 | `Ctrl-t` + C-k | 向上调整面板大小 5 个单位 | +| 交换面板 | `Ctrl-t` + s | 与上方面板交换位置 | +| 关闭面板 | `Ctrl-t` + k | 关闭当前面板 | +| 显示所有面板 | `Ctrl-t` + i | 临时显示所有面板 | diff --git a/Doc/zh/emacs.md b/Doc/zh/emacs.md new file mode 100644 index 0000000..a2f3e68 --- /dev/null +++ b/Doc/zh/emacs.md @@ -0,0 +1,63 @@ +# emacs 配置 + +`dotfiles/.emacs.el` 配置内容概览。 +安装路径:`~/.emacs.el` + +--- + +## 软件包配置 + +添加 MELPA 和 Marmalade 软件包源,并调用 `package-initialize`。 + +```elisp +(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) +(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) +``` + +--- + +## 按键绑定自定义 + +| 按键 | 动作 | +|------|------| +| `Ctrl-Z` | 撤销(覆盖默认的 `suspend-frame`) | + +--- + +## 自动补全(auto-complete) + +使用 `auto-complete-config`。 + +- `TAB` 触发补全 +- 补全菜单显示时用 `Ctrl-N` / `Ctrl-P` 选择候选项 +- 启用模糊匹配 +- 启用的模式:`text-mode`、`fundamental-mode`、`org-mode`、`yatex-mode` + +--- + +## Python 补全(jedi) + +`jedi.el` 提供 Python 代码补全。 + +- 输入 `.` 时自动触发补全(`jedi:complete-on-dot`) +- `` 从 jedi 解绑,用于窗口切换 +- 补全源:文件名 + jedi 直接补全(已移除同模式词汇补全) + +--- + +## 显示设置 + +| 设置 | 效果 | +|------|------| +| `show-paren-mode` | 高亮匹配括号 | +| `global-linum-mode` | 所有缓冲区显示行号(3 位宽) | + +--- + +## 加载路径 + +```elisp +(setq load-path (cons "~/.emacs.d/elisp" load-path)) +``` + +可将本地 Emacs Lisp 文件放置于 `~/.emacs.d/elisp/`。 diff --git a/Doc/zh/htop.md b/Doc/zh/htop.md new file mode 100644 index 0000000..6dd0d2a --- /dev/null +++ b/Doc/zh/htop.md @@ -0,0 +1,84 @@ +# htop + +交互式进程查看器。功能丰富的 `top` 替代工具。 + +--- + +## 启动 + +```bash +htop +``` + +--- + +## 按键绑定 + +### 导航 + +| 按键 | 动作 | +|------|------| +| `↑` / `↓` | 选择进程 | +| `PgUp` / `PgDn` | 翻页 | +| `Home` / `End` | 跳到首条 / 末条 | + +### 排序 + +| 按键 | 动作 | +|------|------| +| `P` | 按 CPU 使用率排序 | +| `M` | 按内存使用量排序 | +| `T` | 按运行时间排序 | +| `F6` 或 `>` | 选择排序列 | +| `I` | 反转排序顺序 | + +### 过滤与搜索 + +| 按键 | 动作 | +|------|------| +| `F3` 或 `/` | 按进程名搜索 | +| `F4` 或 `\` | 过滤(筛选) | +| `F5` | 切换树形视图 | + +### 进程操作 + +| 按键 | 动作 | +|------|------| +| `F9` 或 `k` | 发送信号(kill) | +| `F7` 或 `]` | 降低 nice 值(提高优先级) | +| `F8` 或 `[` | 升高 nice 值(降低优先级) | +| `Space` | 标记进程(多选) | +| `U` | 取消所有标记 | + +### 视图切换 + +| 按键 | 动作 | +|------|------| +| `F2` | 设置界面 | +| `F1` 或 `h` | 帮助 | +| `t` | 切换树形视图 | +| `H` | 显示/隐藏用户线程 | +| `K` | 显示/隐藏内核线程 | + +### 其他 + +| 按键 | 动作 | +|------|------| +| `F10` 或 `q` | 退出 | +| `u` | 仅显示指定用户的进程 | +| `a` | 设置进程的 CPU 亲和性 | + +--- + +## 配置文件 + +设置保存至 `~/.config/htop/htoprc`(可通过 `F2` 配置)。 + +--- + +## 界面说明 + +顶部仪表盘: +- **CPU 条** — 各核心使用率(颜色区分:`user` / `system` / `nice` / `io-wait`) +- **Mem / Swp 条** — 内存与交换空间使用量 +- **Tasks / Load / Uptime** — 进程数、负载均值、系统运行时间 diff --git a/Doc/zh/neofetch.md b/Doc/zh/neofetch.md new file mode 100644 index 0000000..b2da175 --- /dev/null +++ b/Doc/zh/neofetch.md @@ -0,0 +1,65 @@ +# neofetch + +以 ASCII 艺术形式显示系统信息的工具。 + +--- + +## 使用方法 + +```bash +neofetch +``` + +打开新终端或进入新环境时运行,可快速查看操作系统、内核、CPU、内存等系统信息。 + +--- + +## 显示内容 + +| 字段 | 内容 | +|------|------| +| OS | 发行版名称及版本 | +| Host | 主机名与机器型号 | +| Kernel | 内核版本 | +| Uptime | 系统运行时间 | +| Packages | 已安装软件包数量 | +| Shell | 当前 Shell 及其版本 | +| Resolution | 屏幕分辨率(有桌面环境时显示) | +| DE / WM | 桌面环境 / 窗口管理器 | +| Terminal | 终端模拟器 | +| CPU | 处理器名称及核心数 | +| GPU | 显卡(可检测时显示) | +| Memory | 已用内存 / 总内存 | + +--- + +## 常用选项 + +```bash +neofetch --off # 仅显示信息,不显示 ASCII 艺术 +neofetch --ascii_distro ubuntu # 使用其他发行版的 ASCII 艺术 +neofetch --config none # 忽略配置文件运行 +``` + +--- + +## 配置文件 + +在 `~/.config/neofetch/config.conf` 中自定义显示项目、颜色和 ASCII 艺术。 + +```bash +# 生成配置文件(首次使用) +neofetch --config ~/.config/neofetch/config.conf +``` + +主要设置: +- 注释掉 `info` 行可隐藏对应字段 +- 修改 `image_backend` 可使用图片替代 ASCII 艺术(需要 kitty / iTerm2 / WezTerm 等支持的终端) +- 通过 `colors` 自定义配色 + +--- + +## WSL 注意事项 + +在 WSL2 上,GPU 信息和屏幕分辨率可能无法正确获取。 +使用 `neofetch --off` 可稳定显示信息部分。 diff --git a/Doc/zh/secrets.md b/Doc/zh/secrets.md new file mode 100644 index 0000000..9543471 --- /dev/null +++ b/Doc/zh/secrets.md @@ -0,0 +1,79 @@ +# 密钥管理 + +**切勿将 API 密钥、令牌或其他密钥提交到 git 仓库。** +本文档说明如何在 dotfiles 中安全地管理密钥。 + +--- + +## 使用 ~/.zshrc.local(推荐) + +`.zshrc.local` 不受 git 管理,且会由 `~/.zshrc` 自动加载。 + +```bash +# 复制模板 +cp dotfiles/.zshrc.local.example ~/.zshrc.local + +# 用编辑器修改 +$EDITOR ~/.zshrc.local +``` + +`.zshrc.local` 内容示例: + +```zsh +export ANTHROPIC_API_KEY="sk-ant-..." +export GITHUB_TOKEN="ghp_..." +export AWS_DEFAULT_REGION="ap-northeast-1" +``` + +`.gitignore` 中已添加 `*.local`,不会被意外提交。 + +--- + +## 使用 direnv(按项目) + +对于每个项目使用不同凭据的场景,`direnv` 非常方便。 + +```bash +# 在项目目录中 +echo 'export DATABASE_URL="postgresql://localhost/myapp_dev"' > .envrc +direnv allow +``` + +建议将 `.envrc` 添加到项目的 `.gitignore`: + +``` +.envrc +.envrc.local +``` + +--- + +## 密钥管理工具(进阶) + +需要更强大管理时: + +| 工具 | 用途 | +|------|------| +| [1Password CLI](https://developer.1password.com/docs/cli/) | 从 1Password 注入密钥 | +| [Bitwarden CLI](https://bitwarden.com/help/cli/) | 从 Bitwarden 注入密钥 | +| [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) | 云端密钥管理 | +| [HashiCorp Vault](https://www.vaultproject.io/) | 企业级密钥管理 | + +--- + +## 如果不小心提交了密钥 + +1. **立即撤销并轮换密钥** +2. 从 git 历史中删除密钥: + ```bash + # 使用 BFG Repo Cleaner + bfg --replace-text secrets.txt + git reflog expire --expire=now --all + git gc --prune=now --aggressive + git push --force + ``` +3. 通知团队成员 + +> [!CAUTION] +> 一旦推送,即使"已删除",密钥也可能已经泄露。 +> 务必轮换您的密钥。 diff --git a/Doc/zh/tools.md b/Doc/zh/tools.md new file mode 100644 index 0000000..0f65700 --- /dev/null +++ b/Doc/zh/tools.md @@ -0,0 +1,180 @@ +# 工具详情指南 + +`bootstrap.sh` 的 Shell / Dev 模块安装的工具配置与使用说明。 + +--- + +## starship + +**配置文件:** `~/.config/starship.toml`(从 `config/starship.toml` 部署) + +双行提示符。显示当前目录、git 分支、语言版本及命令执行时间。 +Node.js、Python、Rust 等仅在目录下存在相关文件时显示。 + +自定义示例: + +```toml +# starship.toml +[directory] +truncation_length = 3 + +[cmd_duration] +min_time = 5000 # 仅显示执行超过 5 秒的命令 +``` + +--- + +## fzf + +**按键绑定:** + +| 按键 | 动作 | +|------|------| +| `Ctrl-T` | 搜索文件并插入命令行 | +| `Ctrl-R` | 搜索命令历史 | +| `Alt-C` | 交互式切换目录 | + +**自定义函数(fzf.zsh):** + +```zsh +fcd # 模糊切换目录 +fkill # 模糊 kill 进程 +``` + +安装 ripgrep 后,文件搜索会自动遵循 `.gitignore`。 + +--- + +## zoxide + +智能 `cd` 替代。自动学习常用目录。 + +```zsh +z proj # 跳转到包含 "proj" 的常用目录 +z do sh # 跳转到同时匹配 "do" 和 "sh" 的目录 +zi # 通过 fzf 交互式选择 +``` + +--- + +## atuin + +基于 SQLite 的 Shell 历史记录。 + +**按键绑定:** + +| 按键 | 动作 | +|------|------| +| `Ctrl-R` | 模糊历史记录搜索 | +| `↑` | 普通历史记录(方向键未被覆盖) | + +**配置文件:** `~/.config/atuin/config.toml`(从 `config/atuin/config.toml` 部署) + +--- + +## direnv + +按目录自动加载环境变量。 + +```bash +# 在项目中创建 .envrc +echo 'export API_KEY="dev-key"' > .envrc +direnv allow + +# 离开目录后环境变量自动清除 +``` + +--- + +## gh(GitHub CLI) + +```bash +gh pr list # 列出 PR +gh pr create --fill # 创建 PR(从提交信息自动填充) +gh pr checkout 123 # 在本地检出 PR +gh issue create -t "Bug" -b "..." # 创建 Issue +gh repo clone user/repo # 克隆仓库 +``` + +--- + +## ripgrep(rg) + +高速 grep 替代。自动遵循 `.gitignore`。 + +```bash +rg "TODO" # 在当前目录递归搜索 +rg -t py "def main" # 仅搜索 Python 文件 +rg -l "import react" # 仅显示文件名 +rg --hidden "secret" # 包含隐藏文件 +``` + +--- + +## bat + +带语法高亮的 `cat` 替代。 + +```bash +bat file.py # 带语法高亮的输出 +bat --plain file.py # 无行号 +bat -A file.py # 显示不可见字符 +``` + +--- + +## delta + +带语法高亮的 git diff 分页器。由 `_setup_git_config` 自动配置。 + +```bash +git diff # delta 自动生效 +git log -p # 提交差异也使用 delta 显示 +``` + +--- + +## lazygit + +git 的 TUI 客户端。 + +```bash +lazygit # 或 lg +``` + +**lazygit 内部按键:** + +| 按键 | 动作 | +|------|------| +| `s` | 暂存文件 | +| `c` | 提交 | +| `p` | push | +| `P` | pull | +| `?` | 帮助 | + +--- + +## git 别名(commit.zsh) + +| 别名 | 命令 | +|------|------| +| `gs` | `git status -sb` | +| `gd` | `git diff` | +| `gds` | `git diff --staged` | +| `ga` | `git add` | +| `gc` | `git commit` | +| `gcm` | `git commit -m` | +| `gco` | `git checkout` | +| `gcb` | `git checkout -b` | +| `gp` | `git push` | +| `gpf` | `git push --force-with-lease` | +| `gpl` | `git pull --rebase` | +| `glog` | 单行 git log(20 条) | +| `glogg` | 带图形的 git log(30 条) | + +**约定式提交:** + +```bash +gcommit feat "add dark mode" # feat: add dark mode +gcommit fix "login crash" auth # fix(auth): login crash +``` diff --git a/Doc/zh/yazi.md b/Doc/zh/yazi.md new file mode 100644 index 0000000..e7a7c50 --- /dev/null +++ b/Doc/zh/yazi.md @@ -0,0 +1,98 @@ +# Yazi + +终端文件管理器。使用 Rust 编写,异步且高速。 + +--- + +## 启动 + +```bash +yy # 启动 yazi,退出后自动 cd 到对应目录 +yazi # 直接启动(退出后不自动 cd) +``` + +`yy` 是 `.zshrc` 中定义的函数,退出 yazi 后将其目录传回 shell。 +若已在 yazi 内部(`YAZI_LEVEL` 已设置),执行 `exit` 退出内层 shell。 + +--- + +## 按键绑定 + +### 导航 + +| 按键 | 动作 | +|------|------| +| `h` 或 `←` | 进入父目录 | +| `l` 或 `→` / `Enter` | 打开选中项(进入目录) | +| `j` 或 `↓` | 向下移动 | +| `k` 或 `↑` | 向上移动 | +| `gg` | 跳到顶部 | +| `G` | 跳到底部 | +| `H` | 跳到屏幕顶部 | +| `M` | 跳到屏幕中间 | +| `L` | 跳到屏幕底部 | + +### 文件操作 + +| 按键 | 动作 | +|------|------| +| `Space` | 标记文件(多选) | +| `v` | 切换可视模式(全选等) | +| `y` | 复制(yank) | +| `x` | 剪切 | +| `p` | 粘贴 | +| `d` | 移入回收站 | +| `D` | 永久删除(需确认) | +| `a` | 新建文件 / 目录(末尾加 `/` 为目录) | +| `r` | 重命名 | + +### 查看与搜索 + +| 按键 | 动作 | +|------|------| +| `.` | 切换隐藏文件显示 | +| `/` | 按文件名过滤 | +| `f` | 模糊搜索(类似 fzf) | +| `s` | 更改排序方式 | +| `z` | 使用 zoxide 跳转常用目录 | + +### 标签页 + +| 按键 | 动作 | +|------|------| +| `t` | 打开新标签页 | +| `1` ~ `9` | 切换到对应标签页 | +| `[` / `]` | 切换到前 / 后一个标签页 | + +### 其他 + +| 按键 | 动作 | +|------|------| +| `q` | 退出 | +| `~` | 跳到主目录 | +| `-` | 返回上一个目录 | +| `o` | 用默认应用打开 | +| `e` | 用编辑器打开 | +| `i` | 全屏预览 | +| `?` | 显示所有按键绑定 | + +--- + +## 配置文件 + +将配置放置于 `~/.config/yazi/`(未配置时使用默认设置)。 + +``` +~/.config/yazi/ +├── yazi.toml # 全局设置(排序等) +├── keymap.toml # 按键绑定自定义 +├── theme.toml # 主题与配色 +└── plugins/ # 插件 +``` + +--- + +## 预览支持 + +异步预览文本、图片(需支持的终端)、PDF、音频及视频缩略图等多种格式。 +图片预览需要 kitty、iTerm2、WezTerm 等兼容终端。 diff --git a/Doc/zh/zsh.md b/Doc/zh/zsh.md new file mode 100644 index 0000000..4459001 --- /dev/null +++ b/Doc/zh/zsh.md @@ -0,0 +1,116 @@ +# zsh 配置 + +`dotfiles/.zshrc` 配置内容概览。 + +--- + +## 别名 + +| 别名 | 展开 | 说明 | +|------|------|------| +| `ls` | `lsd` | 带图标的目录列表 | +| `l`, `ll` | `ls -l` | 详细格式 | +| `la` | `ls -a` | 包含隐藏文件 | +| `lla` | `ls -la` | 详细格式 + 隐藏文件 | +| `lt` | `ls --tree` | 树形显示 | +| `llt` | `ll --tree` | 详细树形显示 | +| `rm` | `rm -i` | 删除前确认 | +| `cp` | `cp -i` | 覆盖前确认 | +| `mv` | `mv -i` | 覆盖前确认 | +| `mkdir` | `mkdir -p` | 自动创建中间目录 | +| `sudo` | `sudo ` | 在 sudo 后也启用别名 | + +**全局别名(管道后也可展开):** + +| 别名 | 展开 | +|------|------| +| `L` | `\| less` | +| `G` | `\| grep` | + +--- + +## 按键绑定 + +默认启用 Emacs 风格按键绑定(`bindkey -e`)。 + +| 按键 | 动作 | +|------|------| +| `Ctrl-R` | 支持通配符的增量历史记录搜索 | +| `Ctrl-A` | 移动到行首 | +| `Ctrl-E` | 移动到行尾 | +| `Ctrl-W` | 按词删除(分隔符包括 `/=;@:{},|`) | +| `Ctrl-U` | 删除光标之前的所有内容 | +| `Ctrl-K` | 删除光标之后的所有内容 | + +--- + +## 历史记录设置 + +| 设置 | 值 | +|------|-----| +| 大小(`HISTSIZE` / `SAVEHIST`) | 1,000,000 | +| 文件 | `~/.zsh_history` | +| 会话间共享 | `share_history` | +| 去重 | `hist_ignore_all_dups` / `hist_save_nodups` | +| 跳过空格开头的命令 | `hist_ignore_space` | +| 去除多余空格 | `hist_reduce_blanks` | + +--- + +## 主要选项 + +| 选项 | 效果 | +|------|------| +| `auto_cd` | 直接输入目录名即可 `cd` | +| `auto_pushd` | 每次 `cd` 都压入目录栈 | +| `pushd_ignore_dups` | 目录栈不保留重复项 | +| `magic_equal_subst` | `=` 后也进行路径补全 | +| `interactive_comments` | 交互式 shell 中 `#` 视为注释 | +| `no_beep` | 禁用提示音 | +| `extended_glob` | 高级通配符(`**`、`^`、`~`) | +| `auto_menu` | 补全候选多时显示菜单 | + +--- + +## 补全设置 + +- 小写输入匹配大写(`m:{a-z}={A-Z}`) +- `../` 后不补全当前目录 +- `sudo` 后也补全命令名 +- 补全 `ps` 的进程名 + +--- + +## 函数 + +### `chpwd` — cd 后自动 ls + +```zsh +cd ~/project # → 自动执行 lsd 列出目录内容 +``` + +### `yy` — 带目录切换的 yazi 启动器 + +```zsh +yy # 启动 yazi,退出后自动 cd 到对应目录 +``` + +若已在 yazi 内部(`YAZI_LEVEL` 已设置),则执行 `exit` 退出内层 shell。 + +--- + +## 模块化加载 + +追加到 `.zshrc` 末尾的代码块: + +```zsh +# 自动加载 ~/.zshrc.d/*.zsh(由 bootstrap.sh 部署) +for _f in "$HOME/.zshrc.d"/*.zsh; do + [ -r "$_f" ] && . "$_f" +done + +# 机器专属 / 密钥配置(不纳入 git 管理) +[ -f "$HOME/.zshrc.local" ] && . "$HOME/.zshrc.local" +``` + +每个 `.zshrc.d/*.zsh` 文件都带有 `command -v <工具>` 检查,未安装该工具时会安全跳过。 diff --git a/Doc/zsh.md b/Doc/zsh.md deleted file mode 100644 index b646694..0000000 --- a/Doc/zsh.md +++ /dev/null @@ -1,3 +0,0 @@ -# zsh - -- [lsd](https://github.com/lsd-rs/lsd) diff --git a/README.ja.md b/README.ja.md new file mode 100644 index 0000000..982f2ef --- /dev/null +++ b/README.ja.md @@ -0,0 +1,175 @@ +[![Linux](https://github.com/long-910/dotfiles/actions/workflows/linux.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/linux.yml) +[![macOS](https://github.com/long-910/dotfiles/actions/workflows/macos.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/macos.yml) +[![ShellCheck](https://github.com/long-910/dotfiles/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/shellcheck.yml) +[![License](https://img.shields.io/github/license/long-910/dotfiles)](https://github.com/long-910/dotfiles/blob/main/LICENSE) + +[English](README.md) | [日本語](README.ja.md) | [中文](README.zh.md) + +# dotfiles + +macOS・Ubuntu・WSL 向け開発環境セットアップスクリプト集です。 +インタラクティブメニューで必要な機能ブロックだけを選択してインストールできます。 + +--- + +## クイックスタート + +### bootstrap.sh(推奨) + +インタラクティブメニューで機能ブロックを選択してインストール。 + +```bash +git clone https://github.com/long-910/dotfiles.git +cd dotfiles +bash bootstrap.sh +``` + +### install_and_configure.sh(従来版) + +一括インストール。`bootstrap.sh` が使用できない環境向け。 + +```bash +git clone https://github.com/long-910/dotfiles.git +cd dotfiles +chmod +x install_and_configure.sh +./install_and_configure.sh +``` + +--- + +## 機能ブロック + +| ブロック | 含まれるツール | デフォルト | +|---------|--------------|-----------| +| **Core** | zsh, tmux, lsd, emacs, htop, neofetch, yazi | ON | +| **Shell** | starship, fzf, zoxide, atuin | ON | +| **Dev** | gh, ripgrep, direnv, bat, delta, fd, jq, lazygit | ON | +| **Node.js** | fnm + Node LTS + commitizen | OFF | +| **Docker** | Docker CE + Docker Compose | OFF | + +`bootstrap.sh` 起動時に番号を入力して ON/OFF を切り替えられます。 +非インタラクティブ実行も可能です: + +```bash +bash bootstrap.sh --all # 全ブロック +bash bootstrap.sh --module shell # 特定モジュールのみ +bash bootstrap.sh --non-interactive # デフォルト設定で自動実行 +bash bootstrap.sh --list # モジュール一覧表示 +``` + +--- + +## ツール詳細 + +### プロンプト・シェル強化 + +| ツール | 説明 | +|-------|------| +| [starship](https://starship.rs/) | 高速・カスタマイズ可能なクロスシェルプロンプト | +| [fzf](https://github.com/junegunn/fzf) | ファジーファインダー。Ctrl-R でヒストリ検索、Ctrl-T でファイル検索 | +| [zoxide](https://github.com/ajeetdsouza/zoxide) | `cd` の賢い代替。`z proj` で頻繁に使うディレクトリへジャンプ | +| [atuin](https://atuin.sh/) | SQLite ベースのシェルヒストリ。Ctrl-R でファジー検索 | + +### 開発ツール + +| ツール | 説明 | +|-------|------| +| [gh](https://cli.github.com/) | GitHub CLI。PR・Issue をターミナルから操作 | +| [ripgrep](https://github.com/BurntSushi/ripgrep) | 高速 grep 代替。`.gitignore` を自動的に尊重 | +| [direnv](https://direnv.net/) | ディレクトリごとの環境変数自動ロード | +| [bat](https://github.com/sharkdp/bat) | シンタックスハイライト付き `cat` 代替 | +| [delta](https://github.com/dandavison/delta) | シンタックスハイライト付き git diff ページャ | +| [fd](https://github.com/sharkdp/fd) | 高速 `find` 代替 | +| [jq](https://jqlang.github.io/jq/) | コマンドライン JSON プロセッサ | +| [lazygit](https://github.com/jesseduffield/lazygit) | git のターミナル UI | + +### ファイル管理 + +| ツール | 説明 | +|-------|------| +| [lsd](https://github.com/lsd-rs/lsd) | アイコン付き `ls` 代替 | +| [yazi](https://yazi-rs.github.io/) | ターミナルファイルマネージャ。`yy` コマンドで起動し、終了後そのディレクトリに移動 | + +--- + +## カスタマイズ + +### プロンプト (starship) + +`config/starship.toml` を編集してカスタマイズできます。 +インストール後は `~/.config/starship.toml` に配置されます。 + +### ディレクトリ別環境変数 (direnv) + +プロジェクトルートに `.envrc` を作成: + +```bash +export DATABASE_URL="postgresql://localhost/myapp" +export NODE_ENV="development" +``` + +```bash +direnv allow # 初回のみ許可 +``` + +### プロジェクトテンプレート + +`newproject` 関数でプロジェクトを素早く作成できます: + +```bash +newproject node my-app # Node.js プロジェクト +newproject python my-script # Python プロジェクト +``` + +--- + +## 秘密情報の管理 + +API キーや環境固有の設定は **`~/.zshrc.local`** に記載します(git に含まれません)。 + +```bash +cp dotfiles/.zshrc.local.example ~/.zshrc.local +# エディタで ~/.zshrc.local を編集 +``` + +詳細は [Doc/ja/secrets.md](Doc/ja/secrets.md) を参照してください。 + +--- + +## アンインストール + +```bash +bash uninstall.sh +``` + +- `~/.zshrc.d/` 内の配置ファイルを削除 +- `.zshrc`、`.tmux.conf`、`.emacs.el` のバックアップを復元 +- `~/.config/starship.toml`、`~/.config/atuin/config.toml` を削除 +- git の `commit.template` 設定を削除 +- 任意でインストールしたパッケージを削除 + +--- + +## ドキュメント + +- [tmux 設定](Doc/ja/Tmux.md) +- [zsh 設定](Doc/ja/zsh.md) +- [ツール詳細](Doc/ja/tools.md) +- [秘密情報の管理](Doc/ja/secrets.md) +- [emacs](Doc/ja/emacs.md) | [htop](Doc/ja/htop.md) | [neofetch](Doc/ja/neofetch.md) | [yazi](Doc/ja/yazi.md) + +--- + +## 対応環境 + +| 環境 | 状態 | +|------|------| +| macOS (Apple Silicon / Intel) | ✅ | +| Ubuntu 22.04 / 24.04 | ✅ | +| WSL2 (Ubuntu) | ✅ | + +--- + +## ライセンス + +MIT — 詳細は [LICENSE](LICENSE) を参照してください。 diff --git a/README.md b/README.md index f8ff8e3..9be7937 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,175 @@ -[![MacOS](https://github.com/long-910/dotfiles/actions/workflows/macos.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/macos.yml) [![Linux](https://github.com/long-910/dotfiles/actions/workflows/linux.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/linux.yml) +[![macOS](https://github.com/long-910/dotfiles/actions/workflows/macos.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/macos.yml) [![ShellCheck](https://github.com/long-910/dotfiles/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/shellcheck.yml) [![License](https://img.shields.io/github/license/long-910/dotfiles)](https://github.com/long-910/dotfiles/blob/main/LICENSE) +[English](README.md) | [日本語](README.ja.md) | [中文](README.zh.md) -# インストールと設定ファイル適用スクリプト +# dotfiles -このスクリプトは、Zsh、Tmux、Emacs、および `tmux-mem-cpu-load` をインストールし、指定の GitHub リポジトリからそれぞれの設定ファイルを取得・適用します。 +Development environment setup scripts for macOS, Ubuntu, and WSL. +Select and install only the feature blocks you need via an interactive menu. -- [tmux](Doc/Tmux.md) -- [emacs](Doc/emacs.md) -- [zsh](Doc/zsh.md) -- [htop](Doc/htop.md) -- [neofetch](Doc/neofetch.md) -- [yazi](Doc/yazi.md) +--- -## 使用方法 +## Quick Start -1. このリポジトリをクローンします。 +### bootstrap.sh (Recommended) + +Select feature blocks from an interactive menu. ```bash git clone https://github.com/long-910/dotfiles.git +cd dotfiles +bash bootstrap.sh ``` +### install_and_configure.sh (Legacy) + +All-in-one installer. For environments where `bootstrap.sh` is unavailable. + ```bash +git clone https://github.com/long-910/dotfiles.git cd dotfiles +chmod +x install_and_configure.sh +./install_and_configure.sh ``` -2. `install_and_configure.sh` スクリプトを実行可能にします。 +--- + +## Feature Blocks + +| Block | Tools | Default | +|-------|-------|---------| +| **Core** | zsh, tmux, lsd, emacs, htop, neofetch, yazi | ON | +| **Shell** | starship, fzf, zoxide, atuin | ON | +| **Dev** | gh, ripgrep, direnv, bat, delta, fd, jq, lazygit | ON | +| **Node.js** | fnm + Node LTS + commitizen | OFF | +| **Docker** | Docker CE + Docker Compose | OFF | + +Toggle ON/OFF by entering numbers when `bootstrap.sh` starts. +Non-interactive execution is also available: ```bash -chmod +x install_and_configure.sh +bash bootstrap.sh --all # All blocks +bash bootstrap.sh --module shell # Single module +bash bootstrap.sh --non-interactive # Auto with defaults +bash bootstrap.sh --list # List modules ``` -3. スクリプトを実行します。 +--- + +## Tools + +### Prompt & Shell Enhancement + +| Tool | Description | +|------|-------------| +| [starship](https://starship.rs/) | Fast, customizable cross-shell prompt | +| [fzf](https://github.com/junegunn/fzf) | Fuzzy finder. `Ctrl-R` for history, `Ctrl-T` for files | +| [zoxide](https://github.com/ajeetdsouza/zoxide) | Smart `cd` replacement. `z proj` jumps to frequent dirs | +| [atuin](https://atuin.sh/) | SQLite-based shell history. `Ctrl-R` for fuzzy search | + +### Development Tools + +| Tool | Description | +|------|-------------| +| [gh](https://cli.github.com/) | GitHub CLI. Manage PRs and Issues from the terminal | +| [ripgrep](https://github.com/BurntSushi/ripgrep) | Fast grep alternative. Respects `.gitignore` | +| [direnv](https://direnv.net/) | Auto-load per-directory environment variables | +| [bat](https://github.com/sharkdp/bat) | `cat` alternative with syntax highlighting | +| [delta](https://github.com/dandavison/delta) | Git diff pager with syntax highlighting | +| [fd](https://github.com/sharkdp/fd) | Fast `find` alternative | +| [jq](https://jqlang.github.io/jq/) | Command-line JSON processor | +| [lazygit](https://github.com/jesseduffield/lazygit) | Terminal UI for git | + +### File Management + +| Tool | Description | +|------|-------------| +| [lsd](https://github.com/lsd-rs/lsd) | `ls` alternative with icons | +| [yazi](https://yazi-rs.github.io/) | Terminal file manager. Launch with `yy`, cd to exit dir | + +--- + +## Customization + +### Prompt (starship) + +Edit `config/starship.toml` to customize. +After installation, it is placed at `~/.config/starship.toml`. + +### Per-directory Environment Variables (direnv) + +Create `.envrc` in your project root: ```bash -./install_and_configure.sh +export DATABASE_URL="postgresql://localhost/myapp" +export NODE_ENV="development" ``` -4. スクリプトが実行されると、Zsh、Tmux、Emacs、および `tmux-mem-cpu-load` がインストールされ、それぞれの設定ファイルが指定の GitHub リポジトリから取得・適用されます。 +```bash +direnv allow # Required on first use +``` + +### Project Templates + +Quickly scaffold projects with the `newproject` function: + +```bash +newproject node my-app # Node.js project +newproject python my-script # Python project +``` + +--- + +## Secrets Management + +Store API keys and environment-specific settings in **`~/.zshrc.local`** (not committed to git). + +```bash +cp dotfiles/.zshrc.local.example ~/.zshrc.local +# Edit ~/.zshrc.local with your editor +``` + +See [Doc/en/secrets.md](Doc/en/secrets.md) for details. + +--- + +## Uninstall + +```bash +bash uninstall.sh +``` + +- Removes deployed files from `~/.zshrc.d/` +- Restores backups of `.zshrc`, `.tmux.conf`, `.emacs.el` +- Removes `~/.config/starship.toml` and `~/.config/atuin/config.toml` +- Removes git `commit.template` setting +- Optionally removes installed packages + +--- + +## Documentation + +- [tmux](Doc/en/Tmux.md) +- [zsh](Doc/en/zsh.md) +- [Tools](Doc/en/tools.md) +- [Secrets Management](Doc/en/secrets.md) +- [emacs](Doc/en/emacs.md) | [htop](Doc/en/htop.md) | [neofetch](Doc/en/neofetch.md) | [yazi](Doc/en/yazi.md) + +--- + +## Supported Environments -> [!TIP] -> `tmux-mem-cpu-load` は Tmux でメモリと CPU の使用状況を表示するツールです。インストール後、Tmux を起動した際に画面の右下にメモリ使用量と CPU 使用率が表示されます。 +| Environment | Status | +|-------------|--------| +| macOS (Apple Silicon / Intel) | ✅ | +| Ubuntu 22.04 / 24.04 | ✅ | +| WSL2 (Ubuntu) | ✅ | -> [!CAUTION] -> -> - このスクリプトは Debian ベースのシステム(例: Ubuntu)を対象としています。他のディストリビューションを使用している場合は、スクリプトを適切に修正してください。 -> - GitHub リポジトリの URL やファイルパスは、各自の設定に合わせて変更してください。 -> - スクリプトを実行すると、既存の設定ファイルがあればバックアップを作成し、新しいファイルで上書きします。十分に注意して使用してください。 +--- -## ライセンス +## License -このスクリプトは MIT ライセンスのもとで提供されています。詳細については [LICENSE](LICENSE) をご覧ください。 +MIT — See [LICENSE](LICENSE) for details. diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 0000000..967cf18 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,174 @@ +[![Linux](https://github.com/long-910/dotfiles/actions/workflows/linux.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/linux.yml) +[![macOS](https://github.com/long-910/dotfiles/actions/workflows/macos.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/macos.yml) +[![ShellCheck](https://github.com/long-910/dotfiles/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/long-910/dotfiles/actions/workflows/shellcheck.yml) +[![License](https://img.shields.io/github/license/long-910/dotfiles)](https://github.com/long-910/dotfiles/blob/main/LICENSE) + +[English](README.md) | [日本語](README.ja.md) | [中文](README.zh.md) + +# dotfiles + +适用于 macOS、Ubuntu 和 WSL 的开发环境搭建脚本。 +通过交互式菜单选择并安装所需的功能模块。 + +--- + +## 快速开始 + +### bootstrap.sh(推荐) + +通过交互式菜单选择功能模块进行安装。 + +```bash +git clone https://github.com/long-910/dotfiles.git +cd dotfiles +bash bootstrap.sh +``` + +### install_and_configure.sh(传统方式) + +一键安装。适用于 `bootstrap.sh` 无法使用的环境。 + +```bash +git clone https://github.com/long-910/dotfiles.git +cd dotfiles +chmod +x install_and_configure.sh +./install_and_configure.sh +``` + +--- + +## 功能模块 + +| 模块 | 包含工具 | 默认 | +|------|---------|------| +| **Core** | zsh, tmux, lsd, emacs, htop, neofetch, yazi | ON | +| **Shell** | starship, fzf, zoxide, atuin | ON | +| **Dev** | gh, ripgrep, direnv, bat, delta, fd, jq, lazygit | ON | +| **Node.js** | fnm + Node LTS + commitizen | OFF | +| **Docker** | Docker CE + Docker Compose | OFF | + +启动 `bootstrap.sh` 时输入数字来切换 ON/OFF。也支持非交互式执行: + +```bash +bash bootstrap.sh --all # 安装所有模块 +bash bootstrap.sh --module shell # 仅安装指定模块 +bash bootstrap.sh --non-interactive # 使用默认配置自动运行 +bash bootstrap.sh --list # 列出所有模块 +``` + +--- + +## 工具详情 + +### 提示符与 Shell 增强 + +| 工具 | 说明 | +|------|------| +| [starship](https://starship.rs/) | 快速、可定制的跨 Shell 提示符 | +| [fzf](https://github.com/junegunn/fzf) | 模糊查找器。`Ctrl-R` 搜索历史记录,`Ctrl-T` 搜索文件 | +| [zoxide](https://github.com/ajeetdsouza/zoxide) | 智能 `cd` 替代。`z proj` 跳转到常用目录 | +| [atuin](https://atuin.sh/) | 基于 SQLite 的 Shell 历史记录。`Ctrl-R` 模糊搜索 | + +### 开发工具 + +| 工具 | 说明 | +|------|------| +| [gh](https://cli.github.com/) | GitHub CLI。在终端管理 PR 和 Issue | +| [ripgrep](https://github.com/BurntSushi/ripgrep) | 高速 grep 替代。自动遵循 `.gitignore` | +| [direnv](https://direnv.net/) | 按目录自动加载环境变量 | +| [bat](https://github.com/sharkdp/bat) | 带语法高亮的 `cat` 替代 | +| [delta](https://github.com/dandavison/delta) | 带语法高亮的 git diff 分页器 | +| [fd](https://github.com/sharkdp/fd) | 高速 `find` 替代 | +| [jq](https://jqlang.github.io/jq/) | 命令行 JSON 处理器 | +| [lazygit](https://github.com/jesseduffield/lazygit) | git 的终端 UI | + +### 文件管理 + +| 工具 | 说明 | +|------|------| +| [lsd](https://github.com/lsd-rs/lsd) | 带图标的 `ls` 替代 | +| [yazi](https://yazi-rs.github.io/) | 终端文件管理器。用 `yy` 启动,退出后自动切换目录 | + +--- + +## 自定义 + +### 提示符(starship) + +编辑 `config/starship.toml` 进行自定义。 +安装后文件位于 `~/.config/starship.toml`。 + +### 按目录加载环境变量(direnv) + +在项目根目录创建 `.envrc`: + +```bash +export DATABASE_URL="postgresql://localhost/myapp" +export NODE_ENV="development" +``` + +```bash +direnv allow # 首次使用时需要授权 +``` + +### 项目模板 + +使用 `newproject` 函数快速创建项目: + +```bash +newproject node my-app # Node.js 项目 +newproject python my-script # Python 项目 +``` + +--- + +## 密钥管理 + +API 密钥和特定于机器的配置请写入 **`~/.zshrc.local`**(不会提交到 git)。 + +```bash +cp dotfiles/.zshrc.local.example ~/.zshrc.local +# 用编辑器修改 ~/.zshrc.local +``` + +详情请参阅 [Doc/zh/secrets.md](Doc/zh/secrets.md)。 + +--- + +## 卸载 + +```bash +bash uninstall.sh +``` + +- 删除 `~/.zshrc.d/` 中部署的文件 +- 恢复 `.zshrc`、`.tmux.conf`、`.emacs.el` 的备份 +- 删除 `~/.config/starship.toml` 和 `~/.config/atuin/config.toml` +- 删除 git `commit.template` 配置 +- 可选择性地卸载已安装的软件包 + +--- + +## 文档 + +- [tmux 配置](Doc/zh/Tmux.md) +- [zsh 配置](Doc/zh/zsh.md) +- [工具详情](Doc/zh/tools.md) +- [密钥管理](Doc/zh/secrets.md) +- [emacs](Doc/zh/emacs.md) | [htop](Doc/zh/htop.md) | [neofetch](Doc/zh/neofetch.md) | [yazi](Doc/zh/yazi.md) + +--- + +## 支持环境 + +| 环境 | 状态 | +|------|------| +| macOS (Apple Silicon / Intel) | ✅ | +| Ubuntu 22.04 / 24.04 | ✅ | +| WSL2 (Ubuntu) | ✅ | + +--- + +## 许可证 + +MIT — 详情请参阅 [LICENSE](LICENSE)。