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

Rog*_*ter 4 startup sh windows-subsystem-for-linux ubuntu-18.04

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

Run Code Online (Sandbox Code Playgroud)

我尝试在 /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

Run Code Online (Sandbox Code Playgroud)

小智 5

要在每次打开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
Run Code Online (Sandbox Code Playgroud)