103 lines
4.7 KiB
Markdown
103 lines
4.7 KiB
Markdown
# Zed portable configuration
|
||
|
||
This directory is the portable source for Zed settings, keybindings, tasks, extension installation preferences, and the file-exclusion toggle.
|
||
|
||
## 一行安装
|
||
|
||
前置依赖:已安装 Node.js 和 GitHub CLI `gh`。
|
||
|
||
Windows PowerShell:
|
||
|
||
```powershell
|
||
irm https://git.okk.cool/purp1e/zed-sync/raw/branch/master/bootstrap-from-gist.ps1 | iex
|
||
```
|
||
|
||
macOS/Linux:
|
||
|
||
```sh
|
||
curl -fsSL https://git.okk.cool/purp1e/zed-sync/raw/branch/master/bootstrap-from-gist.sh | sh
|
||
```
|
||
|
||
脚本会处理 GitHub 登录并询问 Gist URL/ID。输入已有 Gist 会下载其配置;直接留空会从本仓库种子配置自动创建新的 Secret Gist。随后脚本会备份当前 Zed 配置并完成安装,安装后重启 Zed。
|
||
|
||
For first-machine setup, new-machine onboarding, daily Gist synchronization, and conflict handling, see [`SYNC-MANUAL.zh-CN.md`](./SYNC-MANUAL.zh-CN.md).
|
||
|
||
## Files
|
||
|
||
- `settings.json`: editor settings and extension installation list. Provider secrets are not stored here.
|
||
- `keymap.json`: cross-platform bindings using `secondary-` for Command/Ctrl.
|
||
- `tasks.json`: task template. Script-path placeholders are rendered during installation.
|
||
- `scripts/file-exclusions.json`: the only file to edit when changing permanent or toggleable exclusion rules.
|
||
- `scripts/toggle-file-scan-exclusions.mjs`: updates `file_scan_exclusions` in the active Zed settings.
|
||
- `scripts/settings-sync.json`: machine-local Gist ID and last synchronized hash. Export and import never overwrite it.
|
||
- `scripts/zed-settings-sync.mjs`: single-JSON import, export, hashing, and Gist synchronization.
|
||
- `bootstrap-from-gist.ps1` / `bootstrap-from-gist.sh`: standalone one-line installers for a fresh machine. They download the single JSON directly from Gist and do not need the rest of this directory.
|
||
|
||
## Zed Task Picker commands
|
||
|
||
Open the Task Picker and search for `Zed Settings`:
|
||
|
||
- `Export JSON...` and `Import JSON...` show a native file picker.
|
||
- `Configure GitHub Gist...` accepts an existing Gist ID or complete URL and remembers it on this machine.
|
||
- `Show GitHub Gist Status` compares the current, remote, and last synchronized SHA-256 hashes.
|
||
- `Push to GitHub Gist` creates a new Secret Gist when none is configured; later Push/Pull operations use the remembered Gist and ask before overwriting divergent settings.
|
||
- `Authenticate GitHub...` runs `gh auth login` in the terminal.
|
||
|
||
GitHub CLI (`gh`) must be installed and authenticated. An existing Gist may contain other files; synchronization only creates or replaces `zed-settings-sync.json` inside it.
|
||
|
||
The synchronized JSON is deliberately flat. Its top-level keys are paths such as `settings.json`, `keymap.json`, and `scripts/file-exclusions.json`, whose values are the complete file contents. No version, metadata, `files` wrapper, or hash is embedded. SHA-256 values are calculated at runtime and only the last synchronized value is retained locally.
|
||
|
||
A secret Gist is unlisted, not access-controlled: anyone who obtains its URL can read it. This bundle deliberately excludes API keys, but a synchronized folder or private Git repository is the safer choice for configuration that contains sensitive paths or identifiers.
|
||
|
||
## Installed keybindings
|
||
|
||
- `Mod+R`: open the Task Picker; search for `Zed Settings` to import, export, push, or pull.
|
||
- `Mod+; U`: upload the current single JSON to the configured Gist.
|
||
- `Mod+; D`: download and import the single JSON from the configured Gist.
|
||
- `Mod+9` / `Mod+0`: activate the previous / next tab in the current pane.
|
||
- `Alt+1` through `Alt+5`: activate editor pane 1 through 5.
|
||
- `Mod+Shift+R`: switch to a recent project.
|
||
- `Mod+; K`: reload Zed.
|
||
- `Mod+; C`: focus the Git panel; press it again to focus the commit-message editor.
|
||
|
||
`Mod` is Command on macOS and Ctrl on Windows/Linux because the keymap uses Zed's `secondary-` syntax. `Alt` maps to Option on macOS.
|
||
|
||
## Windows
|
||
|
||
Install this copy into Zed:
|
||
|
||
```powershell
|
||
.\install.ps1
|
||
```
|
||
|
||
Export later changes from Zed back into this directory:
|
||
|
||
```powershell
|
||
.\export.ps1
|
||
```
|
||
|
||
## macOS and Linux
|
||
|
||
Node.js is required for the exclusion toggle and task-template rendering.
|
||
|
||
```sh
|
||
sh ./install.sh
|
||
sh ./export.sh
|
||
```
|
||
|
||
## Private Git synchronization
|
||
|
||
Initialize this directory once and push it to a private remote:
|
||
|
||
```sh
|
||
git init
|
||
git add .
|
||
git commit -m "Add portable Zed configuration"
|
||
git remote add origin <private-repository-url>
|
||
git push -u origin main
|
||
```
|
||
|
||
On another machine, clone the repository and run the platform installer. After changing Zed settings, run the export script, review `git diff`, then commit and push. On other machines, pull and run the installer again.
|
||
|
||
Zed account login does not currently synchronize these files. API keys remain in each machine's system keychain or environment variables and must not be committed.
|