thefuck工具配置与wsl上的问题解决

thefuck工具配置与wsl上的问题解决

社蕙 48 2023-12-11

安装thefuck

直接访问https://github.com/nvbn/thefuck按照环境运行提供的命令。

trouble shooting

我一开始没有看到thefuck wiki这个页面,里面提供了关于thefuck调试的方法,当然我没有使用里面的内容,但是看来覆盖到了我遇到的问题,之后可以一试。

解决thefuck/fuck找不到的问题

打开bash配置文件code ~/.bashrc,加入下面的内容,然后source一下。

PATH="$PATH:$HOME/.local/bin"
eval $(thefuck --alias)

解决wsl上fuck命令运行极慢的问题

我一开始找到的解决方案来自Slow rule eval on WSL #1036,解决方法也许不同但问题的都是相同的:

Try echo $PATH and you probably gonna see a long list there, and that's the reason the fuck is so slow. You can do what's suggested here, microsoft/WSL#1640 (comment), and restart your linux distro.

就是wsl上默认的path太长太长了,thefuck要找半天你可能错在哪里。所以解决方案就是,ban掉其中来自windows的路径,改掉wsl的设置,然后在外面应用:

Instead of trying to fiddle with the path or the registry, just disable the feature.

in WSL:

  sudo vi /etc/wsl.conf

add:

  [interop]
  appendWindowsPath = false

then in Windows find your distro name and terminate it so the config changes are picked up:

  wsl.exe --list
  wsl.exe --terminate <distro_name>

当时脑子一抽没有注意到一件事情,就是这样做vscode的路径也没有掉了,因此要么先which code记录一下位置。如果亡羊补牢的话就是(VScode装在默认位置):

export PATH="$PATH:/mnt/c/Program Files/Microsoft VS Code/bin"

这样VScode就堂堂复活了。