每次我在 Windows 10 上打开 WSL Ubuntu 18.04 时,我都想自动运行这些设置。
alias desktop='cd /mnt/c/Users/Dot/Desktop/ai_files'
export PYTHONPATH=${PYTHONPATH}:${HOME}/ai-safety-gridworlds
export DISPLAY=localhost:0.0
我尝试在/etc/init.d/中制作包含以下内容的 .sh 脚本,但没有成功。
#!/bin/bash
alias desktop='cd /mnt/c/Users/Dot/Desktop/ai_files'
export PYTHONPATH=${PYTHONPATH}:${HOME}/ai-safety-gridworlds
export DISPLAY=localhost:0.0
最佳答案
每次打开 WSL 时运行这些命令,您需要将命令附加到 .bashrc
.
在 bash 中,运行
echo "alias desktop='cd /mnt/c/Users/Dot/Desktop/ai_files'" >> ~/.bashrc
echo "export PYTHONPATH=${PYTHONPATH}:${HOME}/ai-safety-gridworlds" >> ~/.bashrc
echo "export DISPLAY=localhost:0.0" >> ~/.bashrc
关于sh - 我每次在 Windows 10 上打开 WSL Ubuntu 18.04 时都需要运行一个脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56461136/