Skip to content

[FEATURE REQUEST] 增加 -e 参数,用指定命令启动第一个会话 #91

Closed

Description

@rainsuki3527

What it is for

elyterminal -e nvim 应该打开一个窗口,并把该命令作为第一个会话运行,就像 xterm -e、alacritty -e 和 foot -e 那样。编辑器、文件管理器和 xdg-terminal-exec 都是以这种方式调用终端的。

在 0.2.4 上,当 ELYTerminal 是默认终端时,xdg-terminal-exec 已经会拼出这个命令:

$ xdg-terminal-exec --print-cmd --dir=/tmp nvim
elyterminal
--working-directory
/tmp
-e
nvim

它会在打开窗口之前就失败:

$ elyterminal -e nvim
[... ERROR elyterminal] app: more than one argument; usage: elyterminal [FOLDER | --working-directory FOLDER | --startingDirectory FOLDER | -d FOLDER]

src/app/args.rs 里的解析器只接受一个目录参数:裸目录,或跟在 -d、--working-directory、--startingDirectory 之后;不接受其他位置参数。

How it should work

  • 接受 elyterminal [-d FOLDER] -e PROGRAM [ARG...]。-e 之后的所有内容都是程序和它的参数,原样传递,不做 shell 解析。-e 必须是 ELYTerminal 的最后一个选项;只写 elyterminal -e 而没有命令时,打印 usage 并报错。
  • 用该程序在 FOLDER(否则当前目录)启动一个会话。复用 Launch.program(Option<(String, Vec<String>)>),也就是配置文件已经在用的路径;不要启用 shell 集成,行为与带参数的配置文件一致。
  • 程序退出时关闭该会话;如果它是最后一个会话,则关闭窗口。
  • 在 packaging/linux/com.zacharyzhang.elyterminal.desktop 中加入 X-TerminalArgExec=-e。这个 desktop entry 已有 X-TerminalArgDir,但没有 exec 参数,所以 xdg-terminal-exec 目前只能猜 -e;显式声明可以把约定固定下来。
  • 测试:解析器用例(没有命令、目录加 -e、参数里本身含 -e),以及一个运行 sh -c 'exit 0' 的 pty 测试。

References

Checked

  • I searched the open issues for the same request.

Activity

  1. added
    enhancement
    on Nov 11, 2026
  2. Raiden-MeixElysia commented on Nov 14, 2026

    @Raiden-MeixElysia
    Contributor

    主分支已加上,下一版发布:elyterminal -e PROGRAM [ARG...] 把程序作为第一个会话运行,不加载 shell 集成;程序结束时关闭它的窗格;最后一个窗格关闭会话,最后一个会话关闭窗口。-e 之后的每个词都归程序;可以和 -d FOLDER 一起用来指定目录。Linux 的桌面条目写了 X-TerminalArgExec=-e,xdg-terminal-exec 能直接用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions