简体   繁体   English

WSL 将 Bash 和 Ubuntu 应用程序分开,并且无法在我目前在文件资源管理器中的目录中打开“Ubuntu”应用程序

[英]WSL separate Bash and Ubuntu applications and unable to open "Ubuntu" one at directory where I currently am in file explorer

So I'm trying to make WSL work as intended but I'm having some issues.所以我试图让 WSL 按预期工作,但我遇到了一些问题。 First I don't understand why there are separate applications for Bash (comes as soon as you enable WSL) and for Ubuntu (distro you can download from Microsoft Store).首先,我不明白为什么 Bash(一旦启用 WSL 就会出现)和 Ubuntu(发行版,您可以从 Microsoft Store 下载)有单独的应用程序。

I've set up Ubuntu one to have colors and look of how I want it and it also has an icon which is really nice.我已经将 Ubuntu one 设置为具有我想要的颜色和外观,并且它还有一个非常漂亮的图标。 The "Bash.exe" one has no icon but it does have one feature that I can't seem to figure out how to set on "Ubuntu" one - I can right click and open it wherever I want and it automatically starts at the location that I had in file explorer. “Bash.exe”没有图标,但它确实有一项功能,我似乎无法弄清楚如何在“Ubuntu”上进行设置 - 我可以右键单击并在任何我想要的地方打开它,它会自动从我在文件资源管理器中的位置。 I can do the same for "Ubuntu" one (just changing the file to open in regedit) but it won't open at directory I'm currently at.我可以对“Ubuntu”做同样的事情(只是将文件更改为在 regedit 中打开),但它不会在我当前所在的目录中打开。

I'm wondering if there's a way to do that.我想知道是否有办法做到这一点。 If there is none I'm alternatively wondering if there's a way to add icon and change colors of the "bash" one as it seems usual methods of adding icons aren't working for WSL.如果没有,我或者想知道是否有一种方法可以添加图标并更改“bash”的颜色,因为通常添加图标的方法似乎不适用于 WSL。

I suspect that you are accessing the same 'version' of ubuntu with different users/environments/shells.我怀疑您正在使用不同的用户/环境/shell 访问相同的 ubuntu '版本'。 You can prove (or disprove this) by saving a file in the home dir and looking at it in both 'different' installations.您可以通过在主目录中保存文件并在两个“不同”安装中查看它来证明(或反驳)。

example: first open:示例:首先打开:

C:\Windows\System32\bash.exe

and run:并运行:

damo@laptop:~$ cd ~
damo@laptop:~$ pwd
/home/damo
damo@laptop:~$ touch foobar.txt
damo@laptop:~$ ls
foobar.txt
damo@laptop:~$ 

then to compare open: (this is in my case, yours will differ, i changed the default install dir)然后比较开放:(这是在我的情况下,你的会有所不同,我更改了默认安装目录)

C:\_distros\Ubuntu\ubuntu1804.exe

and run the commands:并运行命令:

➜  ~ cd ~
➜  ~ pwd
/home/damo
➜  ~ ls
foobar.txt
➜  ~

For me this difference is that i have installed zsh as the default shell so there are many differences in the two shells try running echo $0 which will show your shell.对我来说,这个区别在于我已经安装了 zsh 作为默认 shell,所以这两个 shell 有很多不同之处,请尝试运行echo $0这将显示您的 shell。

I'm interested to know the outcome of this as for as far as i know simply 'enabling' wsl will not 'install' anything.我很想知道这个结果,据我所知,简单地“启用”wsl 不会“安装”任何东西。

Try option ubuntu1804.exe run .尝试选项ubuntu1804.exe run

Explanation:解释:

My ubuntu1804.exe is in C:\\Users\\walter\\AppData\\Local\\Microsoft\\WindowsApps .我的ubuntu1804.exeC:\\Users\\walter\\AppData\\Local\\Microsoft\\WindowsApps When I open a windows CMD shell (not bash !), I can descend to the folder with ubuntu1804.exe and check the options with /?当我打开 Windows CMD shell(不是bash !)时,我可以使用ubuntu1804.exe进入文件夹并使用/? :

C:\Users\walter\AppData\Local\Microsoft\WindowsApps>ubuntu1804.exe /?
Launches or configures a Linux distribution.

Usage:
    <no args>
        Launches the user's default shell in the user's home directory.

    install [--root]
        Install the distribuiton and do not launch the shell when complete.
          --root
              Do not create a user account and leave the default user set to root.

    run <command line>
        Run the provided command line in the current working directory. If no
        command line is provided, the default shell is launched.

    config [setting [value]]
        Configure settings for this distribution.
        Settings:
          --default-user <username>
              Sets the default user to <username>. This must be an existing user.

    help
        Print usage information.

The option run seems to be what you want.选项run似乎是您想要的。
I tested it from the directory C:\\Users (my wsl .bashrc modifies the prompt)我从目录C:\\Users测试了它(我的 wsl .bashrc修改了提示)

C:\Users>C:\Users\walter\AppData\Local\Microsoft\WindowsApps\ubuntu1804.exe run
walter@wsl:/mnt/c/Users
$   

Bash.exe is deprecated. Bash.exe 已弃用。 use Wsl.exe instead改用 Wsl.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM