终端 > 窗口与标签页
启动配置 (旧版)
# 启动配置(旧版) import { Tabs, TabItem } from '@astrojs/starlight/components'; import VideoEmbed from '@components/VideoEmbed.astro'; :::caution 启动配置已被 [标签页配置 (Tab Configs)](/terminal/windows/tab-configs/) 取代。现有的启动配置仍可继续使用,但不再添加新功能。对于新的设置,请使用 [标签页配置](/terminal/windows/tab-configs/)。 ::: ## 什么是启动配置 借助启动配置,您可以在应用内进行保存,或者通过添加 YAML 文件来进行配置。 ## 创建启动配置 ### 从 UI 创建 1. 设置好您想要保存的窗口、标签页和窗格配置。 2. 打开 [命令面板](/terminal/command-palette/),然后输入 `Save New Launch Configuration`。 3. 为配置文件命名。名称字段不能为空。 4. 点击“Save configuration”(保存配置)按钮。 ### 使用 YAML 文件创建 * 启动配置文件在您通过 UI 创建时会自动生成,也可以手动创建或修改。 * 请参阅下方关于 [启动配置 YAML 文件位置、格式及示例](/terminal/sessions/launch-configurations/#launch-configuration-yaml-format) 的内容。 ## 使用启动配置 <Tabs> <TabItem label="macOS"> * 从 [命令面板](/terminal/command-palette/) 输入 `Launch Configuration` 以打开并选择启动配置。 * 右键点击新的“标签页 **+**”按钮,打开菜单并选择已保存的启动配置。 * 从 macOS 菜单栏选择 **File(文件)** > **Launch Configurations(启动配置)**,您可以在其中搜索并打开已保存的启动配置。 * 使用 macOS 上的 `CMD-ENTER`,可以将单窗口启动配置加载到当前激活的窗口中。 </TabItem> <TabItem label="Windows"> * 从 [命令面板](/terminal/command-palette/) 输入 `Launch Configuration` 以打开并选择启动配置。 * 右键点击新的“标签页 **+**”按钮,打开菜单并选择已保存的启动配置。 * 在 Linux 上,可以使用 `CTRL-ENTER` 将单窗口启动配置加载到当前激活的窗口中。 要使用启动配置打开 WSL 标签页,您必须先在 Warp 中将 WSL 设置为默认 Shell: * 前往 **Settings(设置)** > **Features(功能)** > **Session(会话)** > **Startup shell for new sessions(新会话的启动 Shell)**。 * 选择您所需的 WSL 发行版(例如 Ubuntu)作为默认 Shell。 完成此操作后,您打开的任何启动配置都将使用 WSL 作为 Shell。 </TabItem> <TabItem label="Linux"> * 从 [命令面板](/terminal/command-palette/) 输入 `Launch Configuration` 以打开并选择启动配置。 * 右键点击新的“标签页 **+**”按钮,打开菜单并选择已保存的启动配置。 * 在 Linux 上,可以使用 `CTRL-ENTER` 将单窗口启动配置加载到当前激活的窗口中。 </TabItem> </Tabs> :::tip **终端提示**\ 您可以通过 Alfred 工作流或 [Raycast](/terminal/integrations-and-plugins/#raycast) 扩展程序打开已保存的启动配置。在此 [了解更多信息](https://blog.joe.codes/open-warp-launch-configurations-from-raycast-and-alfred)。感谢 [@joetannenbaum](https://twitter.com/joetannenbaum/status/1633538768866009115) 的贡献 ::: ## 工作原理 <VideoEmbed url="https://www.loom.com/share/daa2a9e55c27458c8bbf722d90078880?hideEmbedTopBar=true&hide_owner=true&hide_share=true&hide_title=true" title="启动配置演示" /> ## 启动配置 YAML 格式 所有启动配置 YAML 文件都存储在以下位置: <Tabs> <TabItem label="macOS"> ```bash $HOME/.warp/launch_configurations/ ``` </TabItem> <TabItem label="Windows"> ```powershell $env:APPDATA\warp\Warp\data\launch_configurations\ ``` </TabItem> <TabItem label="Linux"> ```bash ${XDG_DATA_HOME:-$HOME/.local/share}/warp-terminal/launch_configurations/ ``` </TabItem> </Tabs> :::caution YAML 代码中的 `cwd:` 值必须包含绝对路径或 `""`。请注意,使用 `~` 或留空将导致该文件无法在启动配置选项列表中显示。 ::: ### Windows 示例配置,展示了启动配置文件中窗口的结构。 ```yaml # Warp 启动配置 # # 此配置包含两个窗口, # 每个窗口在不同的起始目录下拥有一个标签页。 --- name: Example Windows windows: - tabs: - title: Documents layout: cwd: /Users/warp-user/Documents color: blue - tabs: - title: Warp User layout: cwd: /Users/warp-user color: green ``` ### 标签页 下面是一个示例配置,展示了启动配置文件中标签页的结构。 * 使用 `title` 字段设置自定义标签页名称 * 使用 `color` 字段设置标签页颜色 * 我们目前支持使用终端颜色(ANSI 颜色):`Red(红) | Green(绿) | Yellow(黄) | Blue(蓝) | Magenta(洋红) | Cyan(青)` 实际颜色值将自动从您的 Warp 主题中获取。 ```yaml # Warp 启动配置 # # 此配置在同一个窗口中有两个标签页。 --- name: Example Tabs windows: - tabs: - title: Documents layout: cwd: /Users/warp-user/Documents color: blue - title: Warp User layout: cwd: /Users/warp-user color: green ``` ### 窗格 启动配置支持在每个标签页中设置拆分窗格。请注意,Warp 也支持在启动配置文件中嵌套拆分窗格。 ```yaml # Warp 启动配置 # # 此配置有两个窗口,每个窗口都有拆分窗格。 # 第一个窗口包含一个垂直拆分的标签页,内有两个窗格。 # 第二个窗口包含一个水平拆分的标签页,右侧有一个垂直拆分。 --- name: Example Panes windows: - tabs: - title: Downloads and Warp User layout: split_direction: vertical panes: - cwd: /Users/warp-user/Downloads - cwd: /Users/warp-user color: blue - tabs: - title: Desktop, Documents, and Warp User layout: split_direction: horizontal panes: - cwd: /Users/warp-user/Desktop - split_direction: vertical panes: - cwd: /Users/warp-user/Documents - cwd: /Users/warp-user color: green ``` ### 激活与聚焦 示例配置展示了如何激活窗口和标签页,并聚焦于特定会话。 * 使用 `active_window_index` 和 `active_tab_index` 字段来设置激活的窗口和标签页。 * 使用 `is_focused` 字段设置每个标签页中聚焦的窗格。 :::caution 请注意,当您使用 `- active_tab_index:` 时,`tabs:` 字段不需要 `-` 前缀,否则可能导致语法错误。 ::: ```yaml # Warp 启动配置 # # 此配置有两个标签页,第二个标签页为激活状态。 # 第一个标签页有两个垂直拆分的窗格,顶部窗格被聚焦。 # 第二个标签页有两个水平拆分的窗格,右侧窗格被聚焦。 --- name: Example Active and Focus active_window_index: 0 windows: - active_tab_index: 1 tabs: - title: Tab 1 layout: split_direction: vertical panes: - cwd: /Users/warp-user/Documents is_focused: true - cwd: /Users/warp-user/Documents/Projects - title: Tab 2 layout: split_direction: horizontal panes: - cwd: /Users/warp-user/Downloads - cwd: /Users/warp-user is_focused: true ``` ### 命令 使用 `commands` 字段来定义运行启动配置时要执行的一组命令。 :::caution 对于包含特殊字符的命令,您可能需要使用双引号。分行的命令在运行时会通过 `&&` 连接,因此在 `ssh` 命令之后运行的命令可能不会执行。 ::: ```yaml # Warp 启动配置 # # 此配置有两个窗口, # 第一个窗口在启动时执行两个命令, # 第二个窗口有一个拆分窗格,在启动时执行一个命令。 --- name: Example Commands windows: - tabs: - title: Documents layout: cwd: /Users/warp-user/Documents commands: - exec: ls - exec: code . color: blue - tabs: - title: Downloads layout: split_direction: vertical panes: - cwd: /Users/warp-user/Downloads commands: - exec: curl http://example.com -o my.file - exec: cp my.file my.file2 - cwd: /Users/warp-user commands: - exec: ssh user@remote.server.com color: green ```启动配置(旧版)允许您保存窗口、标签页和窗格的配置。对于新的设置,请改用“标签页配置 (Tab Configs)”。
它是什么
标题为“它是什么”的章节借助启动配置,您可以在应用内进行保存,或者通过添加 YAML 文件来进行配置。
创建启动配置
标题为“创建启动配置”的章节从 UI 创建
标题为“从 UI 创建”的章节- 设置好您想要保存的窗口、标签页和窗格配置。
- 打开 命令面板,然后输入
Save New Launch Configuration。 - 为配置文件命名。名称字段不能为空。
- 点击“Save configuration”(保存配置)按钮。
使用 YAML 文件创建
标题为“使用 YAML 文件创建”的章节- 启动配置文件在您通过 UI 创建时会自动生成,也可以手动创建或修改。
- 请参阅下方关于 启动配置 YAML 文件位置、格式及示例 的内容。
使用启动配置
标题为“使用启动配置”的章节- 从 命令面板 输入
Launch Configuration以打开并选择启动配置。 - 右键点击新的“标签页 +”按钮,打开菜单并选择已保存的启动配置。
- 从 macOS 菜单栏选择 File(文件) > Launch Configurations(启动配置),您可以在其中搜索并打开已保存的启动配置。
- 使用 macOS 上的
CMD-ENTER,可以将单窗口启动配置加载到当前激活的窗口中。
- 使用 macOS 上的
- 从 命令面板 输入
Launch Configuration以打开并选择启动配置。 - 右键点击新的“标签页 +”按钮,打开菜单并选择已保存的启动配置。
- 在 Linux 上,可以使用
CTRL-ENTER将单窗口启动配置加载到当前激活的窗口中。
- 在 Linux 上,可以使用
要使用启动配置打开 WSL 标签页,您必须先在 Warp 中将 WSL 设置为默认 Shell
- 前往 Settings(设置) > Features(功能) > Session(会话) > Startup shell for new sessions(新会话的启动 Shell)。
- 选择您所需的 WSL 发行版(例如 Ubuntu)作为默认 Shell。
完成此操作后,您打开的任何启动配置都将使用 WSL 作为 Shell。
- 从 命令面板 输入
Launch Configuration以打开并选择启动配置。 - 右键点击新的“标签页 +”按钮,打开菜单并选择已保存的启动配置。
- 在 Linux 上,可以使用
CTRL-ENTER将单窗口启动配置加载到当前激活的窗口中。
- 在 Linux 上,可以使用
工作原理
标题为“工作原理”的章节启动配置 YAML 格式
标题为“启动配置 YAML 格式”的章节所有启动配置 YAML 文件都存储在以下位置
$HOME/.warp/launch_configurations/$env:APPDATA\warp\Warp\data\launch_configurations\${XDG_DATA_HOME:-$HOME/.local/share}/warp-terminal/launch_configurations/Windows
标题为“Windows”的章节示例配置,展示了启动配置文件中窗口的结构。
# Warp Launch Configuration## This configuration has two windows,# each with one tab in different starting directories.
---name: Example Windowswindows: - tabs: - title: Documents layout: cwd: /Users/warp-user/Documents color: blue - tabs: - title: Warp User layout: cwd: /Users/warp-user color: green标签页
标题为“标签页”的章节下面是一个示例配置,展示了启动配置文件中标签页的结构。
- 使用
title字段设置自定义标签页名称 - 使用
color字段设置标签页颜色-
我们目前支持使用终端颜色(ANSI 颜色)
Red(红) | Green(绿) | Yellow(黄) | Blue(蓝) | Magenta(洋红) | Cyan(青)实际颜色值将自动从您的 Warp 主题中获取
-
# Warp Launch Configuration## This configuration has two tabs in the same window.
---name: Example Tabswindows: - tabs: - title: Documents layout: cwd: /Users/warp-user/Documents color: blue - title: Warp User layout: cwd: /Users/warp-user color: green启动配置支持在每个标签页中设置拆分窗格。请注意,Warp 也支持在启动配置文件中嵌套拆分窗格。
# Warp Launch Configuration## This configuration is two windows, each with split panes.# The first window contains a vertically split tab with two panes.# The second window contains a horizontally split tab,# with a vertically split tab on the right.
---name: Example Paneswindows: - tabs: - title: Downloads and Warp User layout: split_direction: vertical panes: - cwd: /Users/warp-user/Downloads - cwd: /Users/warp-user color: blue - tabs: - title: Desktop, Documents, and Warp User layout: split_direction: horizontal panes: - cwd: /Users/warp-user/Desktop - split_direction: vertical panes: - cwd: /Users/warp-user/Documents - cwd: /Users/warp-user color: green激活与聚焦
标题为“激活与聚焦”的章节示例配置展示了如何激活窗口和标签页,并聚焦于特定会话。
- 使用
active_window_index和active_tab_index字段来设置激活的窗口和标签页。 - 使用
is_focused字段设置每个标签页中聚焦的窗格。
# Warp Launch Configuration## This configurations has two tabs, with the second tab active.# Two vertical split panes in the first tab and the top pane focused.# Two horizontal split panes in the second tab and the right pane focused.---name: Example Active and Focusactive_window_index: 0windows: - active_tab_index: 1 tabs: - title: Tab 1 layout: split_direction: vertical panes: - cwd: /Users/warp-user/Documents is_focused: true - cwd: /Users/warp-user/Documents/Projects - title: Tab 2 layout: split_direction: horizontal panes: - cwd: /Users/warp-user/Downloads - cwd: /Users/warp-user is_focused: true使用 commands 字段来定义运行启动配置时要执行的一组命令。
# Warp Launch Configuration## This configuration has two windows,# the first window executes two commands on start,# the second window has a split pane that executes a command on start.
---name: Example Commandswindows: - tabs: - title: Documents layout: cwd: /Users/warp-user/Documents commands: - exec: ls - exec: code . color: blue - tabs: - title: Downloads layout: split_direction: vertical panes: - cwd: /Users/warp-user/Downloads commands: - exec: curl http://example.com -o my.file - exec: cp my.file my.file2 - cwd: /Users/warp-user commands: - exec: ssh user@remote.server.com color: green