Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
qianfanguojin committed Nov 3, 2021
0 parents commit 0cc402b
Show file tree
Hide file tree
Showing 8 changed files with 645 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## 将 Windows Terminal 添加到 Windows 右键菜单的 Powershell 脚本

原项目:

[lextm/windowsterminal-shell](https://github.com/lextm/windowsterminal-shell)

*A project backed by [LeXtudio Inc.](https://www.lextudio.com)*

感谢原作提供的工具,笔者在这里对其中的内容进行翻译,以及本地化修改。

有时候,我们往往需要在某个目录进入控制台窗口,特别是在某个目录打开管理员窗口,而大多数控制台的默认路径都会从用户家目录出发,不太方便。

此脚本的目的就是为了解决这个问题,实现的效果如下:

![image-20211103204906670](default.jpg)

### 安装

1. 安装 Window Terminal [Windows Terminal installation | Microsoft Docs](https://github.com/microsoft/terminal)

2. 安装 PowerShell 7 [在 Windows 上安装 PowerShell - PowerShell | Microsoft Docs](https://docs.microsoft.com/zh-cn/powershell/scripting/install/installing-powershell-on-windows)

3. 使用 **管理员权限** 启动 Powershell 7,然后运行仓库中的 `install.ps1` 文件。程序会自动寻找电脑中的终端和 shell 配置,并将其添加到右键菜单。

> 若要快速运行最新版本的 `install.ps1` 安装脚本,可以将下面的代码复制到 Powershell 7 (管理员权限) 的控制台中运行:
>
> ```powershell
> Set-ExecutionPolicy Bypass -Scope Process -Force;
> [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/qianfanguojin/windowsterminal-menu/master/install.ps1'))
> ```
>
> 若提示下载失败 `"请求的名称有效,但是找不到请求的类型的数据。 (raw.githubusercontent.com:443)"` 等错误,可以将上面的链接替换为如下的链接,感谢 [@jsdeliver](https://cdn.jsdelivr.net/gh) :
>
> ```powershell
> 'https://cdn.jsdelivr.net/gh/qianfanguojin/windowsterminal-menu/install.ps1'
> ```
>
>
### 卸载

用和安装同样的方式,运行仓库中的 `unistall.ps1` 脚本来删除右键菜单中的 `在此处打开 Windows Terminal ` 项。

### 注意

安装步骤中的一键安装命令需要从 Github 获取最新的安装的文件,这可能需要你的网络畅通(你懂的) 。

目前的版本只支持在 Windows10/11 电脑上运行,而且要求 Windows Terminal 是通过 Microsoft Store 或者 `.appx` 方式安装的。

安装脚本必须在 **管理员权限** 模式下运行,不知道 Powershell 如何获取管理员权限的请自行百度或谷歌。

从 Microsoft Store 安装的 Powershell 7 不支持此脚本。

`install.ps1``uninstall.ps1` 仅仅会修改 **当前用户** 的资源管理器右键菜单。如果系统中有多个用户,只有当前登录的用户的右键菜单会被修改。

61 changes: 61 additions & 0 deletions Readme_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PowerShell Scripts to Install/Uninstall Context Menu Items for Windows Terminal


Source Project [lextm/windowsterminal-shell](https://github.com/lextm/windowsterminal-shell)

*A project backed by [LeXtudio Inc.](https://www.lextudio.com)*

Modified By [qianfanguojin.](https://www.qianfanguojin.top)

## Install

1. [Install Windows Terminal](https://github.com/microsoft/terminal).
1. [Install PowerShell 7](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7).
1. Launch PowerShell 7 console as administrator, and run `install.ps1` to install context menu items to Windows Explorer.

> Quickest way to run the latest script from GitHub at an elevated PowerShell 7 console is
> ``` powershell
> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/lextm/windowsterminal-shell/master/install.ps1'))
> ```
Now the menu items are added to Windows Explorer context menu.

![default layout](./source/default.png)

Figure 1: Default layout

> The menu items are organized in the `default` layout. Other layouts such as `mini` and `flat` give different look and feel. To apply an alternative layout (like `mini`), simply run `install.ps1 mini`.
![flat layout](./source/flat.png)

Figure 2: Flat layout

![mini layout](./source/mini.png)

Figure 3: Mini layout

## Uninstall
1. Run `uninstall.ps1` to uninstall context menu items from Windows Explorer.

> To uninstall an alternative layout (like `mini`), run `uninstall.ps1 mini`.
## Notes
The current release only supports Windows 10 machines (Windows Terminal restriction) and Windows Terminal installed via the store or .appx file.

> If Windows Terminal is installed via Scoop, [scripts from another repo](https://github.com/grimux/windowsterminal-shell-scoop/tree/scoop-support) might help.
The install script must be run as administrator.

> That's because it pulls out data from Windows Terminal's installation folder, which is locked down by Windows 10.
PowerShell 7 installed from Microsoft Store is not supported by the scripts (more details can be found in [#37](https://github.com/lextm/windowsterminal-shell/issues/37)).

`install.ps1` and `uninstall.ps1` only manipulate current user's Windows Explorer settings for the context menu items, and do not write to Windows Terminal settings.

> So different users on the same machine must install the context menu items separately, but possibly with different layouts.
Downloading Windows Terminal icon from GitHub (in `install.ps1`) requires internet connection, but in general is just an optional step that won't be executed in most cases.

## More Products
To learn more about other cool products from LeXtudio Inc. , please visit [our homepage](https://www.lextudio.com/#projects).
Binary file added default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0cc402b

Please sign in to comment.