【问题标题】:Can't run powerline-config during startup (in .tmux.conf)启动期间无法运行 powerline-config(在 .tmux.conf 中)
【发布时间】:2020-05-10 06:46:58
【问题描述】:

当我启动 tmux 时,我在尝试配置电力线时遇到了失败。我已经用这个设置了一个环境环境变量:

export POWERLINE_CONFIG_COMMAND=`which powerline-config`

我的~/.tmux.conf 包含以下内容:

if-shell "POWERLINE_CONFIG_COMMAND" \
  run-shell "$POWERLINE_CONFIG_COMMAND tmux setup"

我得到的错误是:

unknown command: /path/to/powerline-config

我可以在 tmux 启动后手动运行 config 命令:

$POWERLINE_CONFIG_COMMAND tmux setup

我不明白为什么 tmux 在启动过程中无法运行命令,而之后它可以正常运行。

【问题讨论】:

    标签: config tmux powerline


    【解决方案1】:

    我不明白你是怎么得到这个错误的。您不应该收到任何消息,并且什么都不会起作用。

    if-shell "POWERLINE_CONFIG_COMMAND" \
      run-shell "$POWERLINE_CONFIG_COMMAND tmux setup"
    

    会失败,因为POWERLINE_CONFIG_COMMAND 不是命令。你的if-shell 应该在POWERLINE_CONFIG_COMMAND 前面有一个$

    假设这是一个错字,在您的实际.conf 中是正确的。然后,问题是 run-shelltmux 运行,如果您在 tmux 会话中键入 <prefix>:,它的运行方式。

    tmux $POWERLINE_CONFIG_COMMAND tmux setup 不是有效命令。

    你可以这样做

       run-shell 'send-keys "$POWERLINE_CONFIG_COMMAND tmux setup" Enter'
    

    如果您希望它在单个窗格中运行。

    【讨论】:

    • 你的假设是正确的,我有一个错字。所以我尝试了你的建议(run-shell 'send-keys "$POWERLINE_CONFIG_COMMAND tmux setup" Enter')并得到了错误:.tmux.conf:58: no current target。所以有些东西不太匹配。我真的只想为我的 tmux 设置正确配置 Powerline。
    • 如果你在进入 tmux 会话后重新加载你的 tmux.conf,它会起作用吗?
    • 是的。这告诉我们什么?
    • 它告诉我们 tmux.conf 在你有任何可用的 tmux 会话之前被执行,并且调用 powerline-config tmux setup 是为 tmux 启动 powerline 的错误方法。 This issue 似乎暗示你应该打电话给powerline-daemon (也许在你的.bashrc 中?)这将为你设置tmux 的东西......也许。我对电力线一无所知。
    • 好的,现在我想我明白了一点。我在我的.bashrc 中打电话给powerline-daemon。我在某个地方读到我需要这样做。也许我没有。我更改了我的.bashrc,现在我打电话给powerline-config tmux setup,一切似乎都在工作。
    猜你喜欢
    • 2020-09-10
    • 1970-01-01
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多