dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Normalised `open` doesn't work as expected on WSL2

Open Jarmos-san opened this issue 2 years ago • 0 comments

First of thanks for sharing your dotfiles, it's been a major source of inspiration to setup my WSL2 machine lately.

So, I tried using the normalised open (line #144 of the .functions file) code snippet on a WSL2 Ubuntu distro & it won't work as expected. I suspect grep can't read the /proc/version file due to missing sudo privileges(?). I bet a better solution would be to grep the output of uname -r which doesn't require sudo privileges.

A possible "better" solution could be:

if [ ! $(uname -s) = 'Darwin' ]; then
        if [ $(uname -r | grep -i 'microsoft') ]; then
                # Ubuntu on Windows using the Linux subsystem
                alias open='explorer.exe';
        else
                alias open='xdg-open';
        fi
fi

EDIT: Provided a "better" solution & I don't mind opening a PR with the above changes 😄

Jarmos-san avatar Nov 11 '21 08:11 Jarmos-san