-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add optional Ghostty setup and package updates #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Theme, font, and visual settings | ||
| theme = Dracula+ | ||
| font-size = 15 | ||
| background-blur-radius = 20 | ||
| background-opacity = 0.85 | ||
| unfocused-split-opacity = 0.35 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # General behavior | ||
| shell-integration = zsh | ||
| copy-on-select = true | ||
| mouse-hide-while-typing = true | ||
| scrollback-limit = 50000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Split creation | ||
| keybind = "super+d=new_split:right" | ||
| keybind = "super+shift+d=new_split:down" | ||
|
|
||
| # Split navigation | ||
| keybind = "super+alt+up=goto_split:up" | ||
| keybind = "super+alt+down=goto_split:down" | ||
| keybind = "super+alt+left=goto_split:left" | ||
| keybind = "super+alt+right=goto_split:right" | ||
|
|
||
| # Close the current split | ||
| keybind = "super+w=close_surface" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Window behavior and layout | ||
| confirm-close-surface = false | ||
| window-padding-x = 16 | ||
| window-padding-y = 16 | ||
| window-inherit-working-directory = false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Ghostty modular configuration | ||
| config-file = "conf.d/general.conf" | ||
| config-file = "conf.d/appearance.conf" | ||
| config-file = "conf.d/window.conf" | ||
| config-file = "conf.d/keybindings.conf" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,14 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import * as p from "@clack/prompts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { brewInstalled, brewInstall } from "../utils/shell.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cpSync, existsSync, rmSync } from "node:fs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { homedir } from "node:os"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { join } from "node:path"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { brewInstall } from "../utils/shell.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CONFIGS_DIR } from "../constants.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** All available GUI applications. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const APPS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| recommended: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { value: "iterm2", label: "iTerm2", hint: "terminal emulator" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { value: "ghostty", label: "Ghostty", hint: "terminal emulator" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { value: "raycast", label: "Raycast", hint: "launcher & productivity" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { value: "visual-studio-code", label: "VS Code", hint: "code editor" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -19,23 +23,47 @@ export const APPS = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function setupGhosttyConfig({ home = homedir() } = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const shouldInitialize = await p.confirm({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: "Initialize Ghostty with the suitup preset?", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| initialValue: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (p.isCancel(shouldInitialize) || !shouldInitialize) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p.log.info("Ghostty config left unchanged"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const destination = join(home, ".config", "ghostty"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (existsSync(destination)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const backup = `${destination}.backup-${new Date().toISOString().replace(/[:.]/g, "-")}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cpSync(destination, backup, { recursive: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p.log.info(`Existing Ghostty config backed up to ${backup.replace(home, "~")}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rmSync(destination, { recursive: true, force: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cpSync(join(CONFIGS_DIR, "ghostty"), destination, { recursive: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p.log.success("Ghostty config initialized at ~/.config/ghostty/"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+36
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果用户的 建议在复制之前,先使用
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Install selected GUI apps via Homebrew Cask. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param {string[]} apps - list of cask names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param {{ configureGhostty?: boolean }} [opts] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function installApps(apps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function installApps(apps, { configureGhostty = true } = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const app of apps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (brewInstalled(app)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p.log.success(`${app} is already installed`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const s = p.spinner(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.start(`Installing or updating ${app}...`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ok = brewInstall(app, { cask: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`${app} is ready`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const s = p.spinner(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.start(`Installing ${app}...`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ok = brewInstall(app, { cask: true }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`${app} installed`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`Failed to install ${app}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`Failed to install ${app}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 直接无条件调用 建议先通过
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (configureGhostty && apps.includes("ghostty")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await setupGhosttyConfig(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,7 +135,7 @@ async function installZshViaManager(manager) { | |
|
|
||
| p.log.step("Installing Zsh..."); | ||
| if (manager === "brew") { | ||
| await runStream("brew install zsh"); | ||
| await runStream("brew install --no-ask zsh"); | ||
| } else if (manager === "apt-get") { | ||
|
Comment on lines
137
to
139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| await runStream("sudo apt-get update && sudo apt-get install -y zsh"); | ||
| } else if (manager === "dnf") { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import * as p from "@clack/prompts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { brewInstalled, brewInstall } from "../utils/shell.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { brewInstall } from "../utils/shell.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** All available CLI tools with metadata. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const CLI_TOOLS = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -27,17 +27,13 @@ export const CLI_TOOLS = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function installCliTools(tools) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const tool of tools) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (brewInstalled(tool)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| p.log.success(`${tool} is already installed`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const s = p.spinner(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.start(`Installing or updating ${tool}...`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ok = brewInstall(tool); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`${tool} is ready`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const s = p.spinner(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.start(`Installing ${tool}...`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ok = brewInstall(tool); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`${tool} installed`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`Failed to install ${tool}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| s.stop(`Failed to install ${tool}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
28
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 与
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ export function brewInstalled(name) { | |
| * Install a Homebrew formula or cask. Returns true on success. | ||
| */ | ||
| export function brewInstall(name, { cask = false } = {}) { | ||
| const args = cask ? ["install", "--cask", name] : ["install", name]; | ||
| const args = cask ? ["install", "--no-ask", "--cask", name] : ["install", "--no-ask", name]; | ||
| try { | ||
| execSync(`brew ${args.join(" ")}`, { stdio: "inherit" }); | ||
| return true; | ||
|
Comment on lines
59
to
63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Homebrew 的 另外,为了支持“始终执行安装或升级检查”的需求,建议在此处新增一个 export function brewInstall(name, { cask = false } = {}) {
const args = cask ? ["install", "--cask", name] : ["install", name];
try {
execSync("brew " + args.join(" "), { stdio: "inherit" });
return true;
} catch {
return false;
}
}
/**
* Upgrade a Homebrew formula or cask. Returns true on success.
*/
export function brewUpgrade(name, { cask = false } = {}) {
const args = cask ? ["upgrade", "--cask", name] : ["upgrade", name];
try {
execSync("brew " + args.join(" "), { stdio: "inherit" });
return true;
} catch {
return false;
}
} |
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -84,7 +84,7 @@ describe("bootstrap step", () => { | |||||||||||||||||||
|
|
||||||||||||||||||||
| await bootstrap({ platform: "darwin" }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| expect(runStream).toHaveBeenCalledWith(expect.stringContaining("brew install zsh")); | ||||||||||||||||||||
| expect(runStream).toHaveBeenCalledWith(expect.stringContaining("brew install --no-ask zsh")); | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
Comment on lines
85
to
88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在移除
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| test("supports Linux package manager selection", async () => { | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请移除
brew install中的--no-ask选项,因为 Homebrew 并不支持该参数,会导致安装失败。如果需要非交互模式,Homebrew 官方推荐使用环境变量NONINTERACTIVE=1(例如NONINTERACTIVE=1 brew install ...)。