每次在Windows 10上打开WSL Ubuntu 18.04时我都需要运行一个脚本

时间:2019-06-05 13:06:23

标签: sh startup ubuntu-18.04 windows-subsystem-for-linux

每次我在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

1 个答案:

答案 0 :(得分:3)

要在每次打开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