【WSL2】 zsh-syntax-highlighting Very low speed on WSL2

7 篇文章 0 订阅
本文介绍了如何通过修改/etc/wsl.conf文件来阻止Windows路径自动添加到WSL的PATH中,以避免混淆不同版本的程序。步骤包括设置appendWindowsPath为false,重启WSL,然后手动添加你需要的Windows执行文件,如VSCode。文章提供了创建别名或脚本来调用Windows程序的方法,并强调了这种方法可以保持WSL环境的整洁。
摘要由CSDN通过智能技术生成

@BigTear

In /etc/wsl.conf (create if it doesn't exist) add:

[interop]
appendWindowsPath=false

Afterwards run wsl --shutdown and open a new session for the changes to take effect. Note that this will mean Windows executables are no longer in your PATH, e.g., commands like code will no longer work. I think this is better anyway bc it unclutters your WSL PATH and could prevent any problems arising from using the Windows version of something accidentally when you meant to use the Linux version. However, you will manually need to re-add all the Windows executables you care about, like code either:

by creating an alias for the executable

alias code="/mnt/c/[your vscode installation directory]/bin/code"

or by creating a new script that redirects code to the executable

#!/usr/bin/env bash

/mnt/c/[your vscode installation directory]/bin/code "$@"

Also if you do that latter, remember you need to run chmod +x on it and make it available in your PATH for it to be executable from anywhere.

e.g.

# assuming "$HOME/.local/bin" exists and is on your PATH...
echo -e '#!/usr/bin/env bash\n/mnt/c/[your vscode installation directory]/bin/code "$@"' > "$HOME/.local/bin/code"
chmod +x "$HOME/.local/bin/code"

You could also just re-add the executable directory to your PATH variable, but I think that defeats the purpose of cleaning /mnt/* entries from your PATH.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值