3 Star 0 Fork 1

Gitee 极速下载/wsl-terminal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/goreliu/wsl-terminal
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

wsl-terminal

用于 Windows Subsystem for Linux (WSL) 的终端模拟器,基于 minttyfattywslbridge2

英文页面

截图

screenshot

查看更多截图

用法

  1. 这里下载最新版本并解压,或者在 cmd.exe 或 WSL 里运行 bash -c "wget https://github.com/mskyaxl/wsl-terminal/releases/download/v0.9.0/wsl-terminal-0.9.0.7z && 7z x wsl-terminal-0.9.0.7z"

  2. 运行 open-wsl.exe 可以在当前目录打开一个 WSL 终端模拟器(wsl-terminal 需要放置在本地的 NTFS 分区上,原因)。

  3. 运行 tools/1-add-open-wsl-terminal-here-menu.js (帮助) 来添加一个 Open wsl-terminal Here 右键菜单到资源管理器上 (运行 tools/1-remove-open-wsl-terminal-here-menu.js 可以将其删除)。 如果你使用 Total Commander, 可以参考 在 Total Commander 中使用 wsl-terminal

  4. run-wsl-file.exe 可以在 wsl-terminal 里运行任何 .sh (以及任何其他的可执行文件,比如 .py .pl 文件) 脚本文件,你可以在文件打开方式里设置使用它来打开文件。

  5. vim.exe 可以使用 WSL 中的 vim 打开任何文件 (在 wsl-terminal 中),支持在打开方式中配置。如果你使用其他编辑器,可以把 vim.exe 重命名成 emacs.exe nvim.exe nano.exe 等等,会调用对应的编辑器打开。

快捷键

按键 功能
Alt + Enter 全屏
Alt + F2 新建窗口
Alt + F3 搜索文本
Ctrl + [Shift] + Tab 切换窗口
Ctrl + = + - 0 缩放
Ctrl + 鼠标左键 打开光标处的文件、目录名或者网址
Ctrl + 鼠标右键 打开右键菜单

将 wsl-terminal 绑定到快捷键

命令行参数

open-wsl

用法: open-wsl [选项]...
  -a: 激活在运行的 wsl-terminal 窗口。
      如果 use_tmux=1,会 attach 到正在运行的 tmux 会话上。
  -l: 运行一个 login shell 并且切换到家目录(如果 use_tmux=1 则失效)。
  -c command: 运行命令 (例如 -c "echo a b; echo c; cat")。
  -e commands: 运行后边的所有命令 (例如 -e echo a b; echo c; cat)。
  -C dir: 进入到 dir 目录中,WSL 目录(例如 /home/username)。
  -W dir: 进入到 dir 目录中,Windows 目录(例如 c:\Users\username)。
  -d distro: 切换发行版。
  -b "options": 传递额外的选项给 wslbridge。
  -B "options": 传递额外的选项给 mintty。
  -h: 显示帮助信息。

-B-b 后可以添加的选项,请参考 mintty 参数wslbridge2 参数

cmdtool(在 WSL 中运行)

用法: cmdtool [选项]...
  wcmd: 使用 cmd.exe /c 运行 Windows 程序。
  wstart: 使用 cmd.exe /c start 运行 Windows 程序。
  wstartex 文件路径|网址: 和 wstart 类似,但使用 WSL 风格的路径。
  update: 检查更新,如果有更新可以直接升级。
  killall: 杀死所有的 WSL 进程。
  install dash: 安装 Cygwin 中的 dash(用于调试)。
  install busybox: 安装 Cygwin 中的 busybox(用于调试)。

工具

tools 目录下的工具:

文件名 功能
1-add-open-wsl-terminal-here-menu.js 添加 Open wsl-terminal Here 右键菜单到资源管理器上。
1-remove-open-wsl-terminal-here-menu.js 移除 Open wsl-terminal Here 右键菜单。
2-add-wsl-terminal-dir-to-path.js wsl-terminal 目录添加到 Path 环境变量里。
2-remove-wsl-terminal-dir-from-path.js Path 环境变量中移除 wsl-terminal 目录。
3-write-distro-to-config-file.js 将所有发行版的 guid 写入到配置文件 etc/wsl-terminal.conf 中。
4-create-start-menu-shortcut.js 创建一个开始菜单快捷方式,指向 open-wsl -C ~
4-create-start-menu-shortcut-login-shell.js 创建一个开始菜单快捷方式,指向 open-wsl -l
4-remove-all-start-menu-shortcuts.js 移除所有 wsl-terminal 的开始菜单快捷方式。
5-add-open-with-vim-menu.js 添加 Open with vim in wsl-terminal 右键菜单到资源管理器上。
5-remove-open-with-vim-menu.js 移除 Open with vim in wsl-terminal 右键菜单。
6-set-default-shell.bat 设置 etc/wsl-terminal.conf 中的 shell 为 WSL 中用户的 shell。

双击 .js 文件即可运行。如果 .js 文件被某个编辑器关联上了,可以修改打开方式为 Microsoft (R) Windows Based Script Host,或者在 tools 目录运行一个 cmd.exe,然后用 wscript xxx.js 运行对应文件。

配置文件

etc/wsl-terminal.conf 是 wsl-terminal 的配置文件:

[config]
title="窗口标题"
shell=/bin/bash
use_tmux=0
;icon=
;distro=

etc/themes/ 目录下的是主题文件,使用主题

etc/minttyrc 是 mintty 的配置文件, mintty 帮助

升级

wsl-terminal 里打开 open-wsl.exe,然后运行 ./cmdtool update 可以检查 wsl-terminal 的最新版本然后升级。如果下载速度过慢,可以先使用其他方法从发布页面下载 wsl-terminal-v{version}.7z 文件,然后将其放入到 wsl-terminal 目录,然后运行 ./cmdtool update

该工具依赖 wget7z 命令(安装方法。Ubuntu: apt install wget p7zip-full, Archlinux: pacman -S wget p7zip)。

升级过程不会覆盖配置文件,etc/wsl-terminal.confetc/minttyrc 会被放置到 etc/wsl-terminal.conf.pacnewetc/minttyrc.pacnew。升级后 bin 目录会残余一些 .bak 文件,因为这些文件还在运行,不能被删除。下一次升级时,会将之前的 .bak 文件全部删除,你也可以等那些进程退出后手删除那些文件。

使用 tmux

  1. 在 WSL 里安装 tmux。

  2. etc/wsl-terminal.conf 中设置 use_tmux=1。如果版本号低于 0.8.1,还需要添加 attach_tmux_locally=1

  3. 添加如下代码到 ~/.bashrc(如果配置的是 shell=/bin/bash)或者 ~/.zshrc(如果配置的是 shell=/bin/zsh):

[[ -z "$TMUX" && -n "$USE_TMUX" ]] && {
    [[ -n "$ATTACH_ONLY" ]] && {
        tmux a 2>/dev/null || {
            cd && exec tmux
        }
        exit
    }

    tmux new-window -c "$PWD" 2>/dev/null && exec tmux a
    exec tmux
}

然后 open-wsl 就会使用 tmux 了。

切换发行版

使用 open-wsl -d distro (在 cmd.exe 里运行)来切换发行版:

# 列出所有发行版
> wslconfig /l
Legacy (默认)
Ubuntu

# 使用 Ubuntu(会运行 wslconfig /s Ubuntu 然后打开 wsl-terminal)
> open-wsl -d Ubuntu

# Ubuntu 已经是默认的发行版了
> wslconfig /l
Ubuntu (默认)
Legacy

如果你不想修改默认的发行版,可以在 etc/wsl-terminal.conf 里设置 distro_guid

运行 tools/3-write-distro-to-config-file.js帮助),然后会有窗口弹出结果:

result has been written to ..\etc\wsl-terminal.conf:

;distro=kali-linux

;distro=Ubuntu}

remove the ; before distro_guid to use the distro.

可以去掉 distro_guid 前边的 ; 来使用对应的发行版。

如果你想通过命令行将 distro_guid 传递给 open-wsl

# 将 distro 传递给 wslbridge
> open-wsl -b "--distro Ubuntu"

链接

常见问题

反馈建议

发布页面

文档帮助

编译

确保已经在 WSL 里安装了这些 wget tar xz gzip p7zip (安装方法。Ubuntu: apt install wget tar xz-utils gzip p7zip-full, Archlinux: pacman -S wget tar xz gzip p7zip)。

运行 build.bat

许可

MIT

MIT License Copyright (c) 2016 Gore Liu, 2020 Alex Mosky. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Windows 10 中包含了一个 WSL (Windows Subsystem for Linux)子系统,我们可以在其中运行未经修改过的原生 Linux ELF 可执行文件 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/mirrors/wsl-terminal.git
git@gitee.com:mirrors/wsl-terminal.git
mirrors
wsl-terminal
wsl-terminal
master

搜索帮助