2024, Practical Enhancements for Windows Development and Usage Experience - Terminal & Command Line Edition
Hmph, is Windows Terminal a disaster zone? Using scoop to install software, Starship for beautification, but WinSW auto-start is still trash. Tsk, another scoop-search replacing the original, gow to complement Unix tools, gsudo to simulate sudo, but proxychains seems a bit odd. Oh, blessed-contrib dashboard? Just for fun, better to use erdtree to view directories.
目录25 个章节
Preface
Building on earlier groundwork, I'm finally continuing the updates here. This will most likely be the last installment in this series for now.
Additionally, I've incorporated some previous content updates into this piece as well.
Supplementary Notes on the Scoop Package Manager
This section provides additional information and tips for managing software using the Scoop command-line installer for Windows.
Common Scoop Commands
scoop help # View help
scoop help <some command> # View help for a specific command
scoop info <app> # View APP information
scoop install <app> # Install APP
scoop uinstall <app> # Uninstall APP
scoop reset [app]@[version] # Switch versions
scoop list # List installed apps
scoop search # Search for apps
scoop status # Check which apps have updates
scoop update # Update Scoop itself
scoop update appName1 appName2 # Update certain apps
scoop update * # Update all apps (requires operating within the apps directory)
scoop bucket known # Use this command to list all known buckets (software sources)
scoop bucket add bucketName # Add a specific bucket
scoop cache rm <app> # Remove the cache for a specific app
scoop cache rm * # Remove all caches
scoop cleanup <app> # Delete old versions
scoop Frequently Asked Questions
Hash check errors when installing software
- If the error persists after multiple installation attempts, locate its JSON file, download it locally, modify its hash value, and upload it to your own bucket, then update it.
- Use the
scoop install -soption to ignore the hash check. For specific usage, refer toscoop help install
How to remove old versions of software when updating
Use the scoop cleanup command. For specific usage, see scoop help cleanup
Terminal
OK, we've arrived at a major pain point in the Windows development experience.
The command line has always been a weakness of Windows, but with some Rust toolchains (Rust 工具链), this situation can be gradually improved.
Nerd Fonts
To beautify your terminal interface, start by installing a Nerd Font.
This is where a package manager comes in handy again—you can install it using Scoop.
First, add the bucket:
scoop bucket add nerd-fonts
Project URL: https://github.com/matthewjberger/scoop-nerd-fonts
Then, choose a font you like and install it:
scoop install FiraCode-NF
Additionally, this bucket contains many fonts and is no longer limited to Nerd Fonts. You can also install some regular fonts, for example:
scoop install SarasaGothic-SC # Install Sarasa Gothic (Simplified Chinese)
scoop install Wenquanyi-Microhei # Install WenQuanYi Micro Hei
scoop install Wenquanyi-Zenhei # Install WenQuanYi Zen Hei
References
Built-in PowerShell
To get straight to the point: the built-in PowerShell is garbage.
I do not recommend using oh-my-posh, as its startup speed is too slow. PowerShell's startup is already slow, and adding oh-my-posh makes it even slower.
For terminal customization, just use Starship. I will introduce it later.
How to edit the configuration: nano $PROFILE
Here is my configuration:
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/amro.omp.json" | Invoke-Expression
Import-Module gsudoModule
set-alias -name ll -value ls set-alias -name ef -value dotnet-ef
starship
Invoke the Starship prompt in PowerShell Set the environment variable for Starship configuration
Invoke-Expression (&starship init powershell)
$ENV:STARSHIP_CONFIG = "$HOME\.config\starship\plain-text-symbols.toml"
PowerShell 7
This is Microsoft's new open-source, cross-platform terminal, which is a bit more powerful and performant than the built-in PowerShell. (Judging from the project repository, it's developed using C#, which helps with good cross-platform support.)
Project Address: https://github.com/PowerShell/PowerShell
Just download an installer and you're good to go.
My $PROFILE configuration
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineKeyHandler -Chord Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
Set-PSReadLineOption -PredictionViewStyle ListView
set-alias -name ll -value ls
starship
Invoke-Expression (&starship init powershell) $ENV:STARSHIP_CONFIG = "$HOME.config\starship\gruvbox-rainbow.toml"
### Starship
- Configuration - https://starship.rs/zh-CN/config/
- Presets - https://starship.rs/zh-CN/presets/
### NuShell
https://www.nushell.sh/zh-CN/book/
### References
- Unifying the styles of cmd, PowerShell, Git Bash, etc., with Starship - https://zhuanlan.zhihu.com/p/674148271
- Step-by-step guide to building a modern unified terminal (Alacritty + Zellij -> WezTerm) - https://zhuanlan.zhihu.com/p/436024560
## Command Line Tools
### WinSW
A process management tool, similar to `supervisor` in Linux, which can install programs to run as services and set them to run automatically.
#### Installation
```bash
scoop install winsw
Usage
Similar to supervisor, write a configuration file, then install the service, which can be started, stopped, etc.
My Directory Structure
Here, I have set up two services: vnc and frpc.
WinSW
├─ config
│ ├─ vnc.xml
│ ├─ vnc.wrapper.log
│ ├─ vnc.out.log.old
│ ├─ vnc.out.log
│ ├─ vnc.err.log.old
│ ├─ vnc.err.log
│ ├─ frpc.xml
│ ├─ frpc.wrapper.log
│ ├─ frpc.out.log.old
│ ├─ frpc.out.log
│ ├─ frpc.err.log.old
│ └─ frpc.err.log
└─ WinSW.exe
Configuration File Content
Taking frpc.xml as an example.
<service>
<id>frpc</id>
<name>frpc</name>
<description>frp自动启动</description>
<executable>D:\softwares\frp\frpc-a.exe</executable>
<arguments>-c D:\softwares\frp\frpc.ini</arguments>
<log mode="roll"></log>
<startmode>Automatic</startmode>
</service>
Install the Service and Start
Type the command.
# Install Service
winsw install ./config/frpc.xml
# Start
winsw start ./config/frpc.xml
That's it.
For now, use this until a better tool is found.
Known Issues
I frequently encounter the issue of this tool failing to start automatically on boot. Even when I check the Service Manager and confirm that the installed service is set to Automatic and enabled, it still does not start upon startup.
I'm not sure what the problem is, and I'm currently looking for an alternative to WinSW.
scoop-search
Since scoop is written using PowerShell scripts, the search speed becomes relatively slow after adding many buckets.
An expert wrote a new search tool that is much faster than the original, using the Zig language, which I hadn't heard of before.
Project URL: https://github.com/shilangyu/scoop-search
Installation Method
scoop install scoop-search
If you want to replace the original search with scoop-search, you can add the following configuration to $profile.
Invoke-Expression (&scoop-search --hook)
Comparison with the original version
> scoop search curl
Results from local buckets...
Name Version Source Binaries
---- ------- ------ --------
curl 8.6.0_2 main
curlie 1.7.2 main
gnupg1 1.4.23 main gpgkeys_curl.exe
gow 0.8.0 main curl.exe
grpcurl 1.8.9 main
scoop-search
x scoop-search curl
'main' bucket:
curl (8.6.0_2)
curlie (1.7.2)
gnupg1 (1.4.23) --> includes 'gpgkeys_curl.exe'
gow (0.8.0) --> includes 'curl.exe'
grpcurl (1.8.9)
Gow
Completing the Unix Toolchain on Windows
Project URL: https://github.com/bmatzelle/gow
Gow (Gnu On Windows) is the lightweight alternative to Cygwin. It uses a convenient Windows installer that installs about 130 extremely useful open source UNIX applications compiled as native win32 binaries. It is designed to be as small as possible, about 10 MB, as opposed to Cygwin which can run well over 100 MB depending upon options.
It contains over a hundred Unix-like utilities, for example, the nano editor I often use.
The specific tool list is available here: https://github.com/bmatzelle/gow/wiki/executables_list
Installation is simple, using Scoop:
scoop install gow
gsudo
A sudo tool for Windows
In Linux, to execute a command with administrator privileges, you simply prepend sudo. This is quite cumbersome on Windows, as it requires opening a dedicated PowerShell window in administrator mode.
This small tool solves this problem. Its usage is identical to the sudo command in Linux.
PS: Good news is that Microsoft plans to add a native
sudocommand in Windows 11.
Installation
scoop install gsudo
proxychains
Command-line proxy tool
Commonly used in Linux, and surprisingly also works on Windows, (but seems to have some strange issues)
Installation
scoop install proxychains
erdtree
A file tree display tool developed in Rust
Convenient for showing directory structure when writing articles—no need to screenshot the directory structure.
Installation
scoop install erdtree
Common parameters I use
erd -L 3 --dir-order last -y inverted --suppress-size -.
Parameter descriptions:
-L 3: Traverse 3 levels of directories--dir-order last: Display directories first-y inverted:-ysets the layout; options includeregular,inverted,flat, andiflat--suppress-size: Hide file sizes-.: Show hidden files
blessed-contrib
This is a command-line dashboard component library built on Nodejs. While it may not have much practical use, it's fun to play with. As we all know, Linux has many interesting command-line tools, but Windows has fewer. Since this is developed with Nodejs, it's cross-platform and can also be used on Windows.
Project URL: https://github.com/yaronn/blessed-contrib
Usage
git clone https://github.com/yaronn/blessed-contrib.git
cd blessed-contrib
npm install
node ./examples/dashboard.js
Requires a Nodejs environment to be installed, which is slightly more cumbersome. It would be great if there were similar tools developed in Go or Rust.
Add to $profile for convenient future use. Open the configuration file.
nano $profile
Add a PowerShell function.
function dashboard {
node "C:\path\to\blessed-contrib\examples\dashboard.js"
}
Subsequently, you can simply type the dashboard command.
_EOF_
2024, Practical Enhancements for Windows Development and Usage Experience - Terminal & Command Line Edition
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
Windows也能拥有好用的命令行吗?Powershell+Terminal折腾记录(v1.0版本)
Windows一向以图形化操作入门容易著称,所以对于命令行的支持一直为人所诟病,比起Linux或者mac都是被吊打的。这一局面在最近几个版本的Windows10更新里,特别是微软官方出了WindowsTerminal这个大杀器之后有所改善~ 所以对于标题的这个问题,只能说「勉强可以吧」,本文介绍几个折腾命令行的方法。 效果图 ~~偷一张官方的截图,应该没人发现吧~~ 建议先熟读官方文档:https
2024-02-29 · Windows · 约 1 分钟
2024年,提升Windows开发和使用体验的实践经验 - RIME输入法
上一篇文章介绍了 Windows 下的包管理器,本文继续介绍输入法。 事实上 Windows 的输入法生态比 Linux/Mac 丰富很多,不过很多国产输入法存在窃取隐私、植入广告、乱安装流氓软件等问题,现在有开源的 RIME 输入法可以选择,何必受这气呢
2024-02-29 · Windows · 约 1 分钟
使用命令行删除 Windows 网络映射驱动器
Windows 这破系统至今还卡死右键菜单?命令行删映射盘算个事。真就没人修复这 XP 时代的老问题?
2025-10-02 · Windows · 约 1 分钟
解决Windows蓝牙耳机音质差的问题
Windows 把蓝牙耳机麦克风一调用就切 HFP,全损音质,真当用户听不出来?mmsys.cpl 里把录制设备禁掉,世界清净。这破系统还得手动治。
2026-11-12 · Windows · 约 1 分钟
讨论
共 0 条加载评论中…