代码之家  ›  专栏  ›  技术社区  ›  Michael Cole

在带有Ubuntu WSL和Zsh的Windows终端中打开选项卡

  •  0
  • Michael Cole  · 技术社区  · 4 年前

    我正在写一个在Windows下运行UBUNTU WSL的脚本。我使用zsh作为shell,但是bash也可以在这里工作。

    我想使用bash脚本 wt.exe (Windows终端)以打开一些新选项卡。

    以下是我目前掌握的情况:

    #!/bin/bash
    
    cmd.exe /c "wt.exe" \
      new-tab --title 'a' --tabColor "#f00" wsl.exe "ls" \; \
      new-tab --title 'b' --tabColor "#f33" wsl.exe zsh -is -c "ls" \; \
      new-tab --title 'c' --tabColor "#f99" wsl.exe zsh -is "ls" \; \
      new-tab --title 'd' --tabColor "#0f0" wsl.exe zsh -i -c "ls" \; \
      new-tab --title 'e' --tabColor "#3f3" wsl.exe zsh -c "ls" \; \
      new-tab --title 'f' --tabColor "#9f9" wsl.exe zsh "ls" \; \
    

    你需要Windows 10 w/Ubuntu WSL和Windows终端才能工作。

    这个bash脚本会打开一系列选项卡。

    • 注意 ls 马上离开。
    • 错误标签随处可见。

    enter image description here 我想自动化:

    • 打开不同文件夹中的多个选项卡:
    • 运行命令(Thread dev)
    • 取消该命令(ctrl-c),让终端交互,而不是退出。

    我在这些工具的前一个版本中使用了这个,但它们发生了变化。

    新方法是什么?

    0 回复  |  直到 4 年前
        1
  •  1
  •   Michael Cole    4 年前

    zsh ls 没有道理。一般来说

    zsh some_file
    

    请zsh翻译 some_file 作为包含zsh脚本的文本文件。调用外部命令 ls ,你至少得写信

    zsh -c ls
    

    在您的情况下,将其作为登录shell运行(取决于您如何配置zsh)可能有意义。然后,调用将类似于

    zsh -lc ls
    

    当然,zsh会在这之后立即退出,因为您不会打开交互式shell。为了实现这一点,您可以在 ls 已执行以下操作:

    zsh -lc "ls; zsh"