Win Shell

Posted by Zhenda on Tue, Nov 12, 2024
Total Views:

windows系统的终端

  • cmd
  • windows powershell

环境变量的增删改查

cmd

1
2
3
4
5
set
set Path

set Path=xxx
set Path=xxx;%Path%

windows powershell

1
2
3
4
5
6
7
8
ls env:
$env:MY_VAR
Get-Command -Name node -All

$env:MY_VAR = "InitialValue"
$env:MY_VAR = "InitialValue;$env:MY_VAR"
$env:PYTHONPATH = "$env:PYTHONPATH;$(Get-Location)"
rm env:MY_VAR

自动关联系统默认程序,快速打开

1
start .

额外配置

自定义 powershell

1
notepad $PROFILE

编辑

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 默认的别名
# Set-Alias pwd Get-Location
# Set-Alias ls Get-ChildItem
# Set-Alias cd Set-Location
# Set-Alias cat Get-Content
# Set-Alias cp Copy-Item
# Set-Alias rm Remove-Item
# Set-Alias mv Move-Item
# Set-Alias mkdir New-Item -ItemType Directory
# Set-Alias -Name clear -Value Clear-Host
# Set-Alias -Name history -Value Get-History




# Set-Alias -Name which -Value Get-Command

# 创建自定义函数
function touch {
    param (
        [string]$path
    )
    New-Item -ItemType File -Path $path -Force
}



# 进程/服务操作
Set-Alias -Name top -Value Get-Process
Set-Alias -Name kill -Value Stop-Process

# 网络操作
Set-Alias -Name ping -Value Test-Connection
Set-Alias -Name wget -Value Invoke-WebRequest

windows 命令行安装工具

工具安装方式软件源主要优点适合人群官网
ChocolateyPowerShell 一行社区仓库 + 官方软件包最全、丰富普通用户 / IT 管理员
ScoopPowerShell 一行官方 bucket + 社区 bucket极简、无管理员权限开发者 / 轻量使用者https://github.com/ScoopInstaller/Scoop
winget (Windows Package Manager)系统预装Microsoft + 社区Windows 官方支持Windows 用户 / 企业https://learn.microsoft.com/zh-cn/windows/package-manager/winget/help
Ninite安装器官方精选最简单一次安装新手 / 想一次安装应用
AppGet (已合并到 winget)CLI过去的独立方案曾用用户
NuGetCLI.NET 包(专注库).NET 生态专业依赖.NET 开发者
1
2
3
4
5
scoop help
scoop install git

winget help
winget install git

windows port

https://blog.csdn.net/zt15732625878/article/details/80904437