Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to open browser in WSL2 #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix to open browser in WSL2 #1

wants to merge 1 commit into from

Conversation

kachick
Copy link
Owner

@kachick kachick commented Mar 24, 2024

@@ -106,7 +106,13 @@ elif [[ $# -gt 1 ]]; then

case "$(uname -s)" in
Darwin) open "$url$path" ;;
*) xdg-open "$url$path" ;;
*)
if [[ -e '/proc/sys/fs/binfmt_misc/WSLInterop' ]] && ! command -v 'xdg-open' > /dev/null 2>&1; then
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't in podman-machine-default even if it is a WSL...

kachick added a commit to kachick/dotfiles that referenced this pull request Mar 24, 2024
@kachick
Copy link
Owner Author

kachick commented Apr 8, 2024

1! gh repo view -b 8a6ee98 --web
Opening github.com/kachick/dotfiles/tree/8a6ee98 in your browser.
exec: "xdg-open,x-www-browser,www-browser,wslview": executable file not found in $PATH

wslview is included in ubuntu-wsl
🤔

@kachick
Copy link
Owner Author

kachick commented Apr 8, 2024

  (pkgs.writeShellApplication {
    name = "cross-platform-url-open";
    runtimeInputs = with pkgs; [ coreutils ];
    text = ''
      urlpath="$1"

      case "$(uname -s)" in
        Darwin)
          open "$urlpath"
          ;;
        *)
          # This condition maybe not enough for example podman-machine-default, but atleast worked on Ubuntu-22.04
          if [[ -e '/proc/sys/fs/binfmt_misc/WSLInterop' ]]; then
            explorer.exe "$urlpath"
          else
            xdg-open "$urlpath"
          fi
          ;;
      esac
    '';
    meta = {
      description = "open URL with considering WSL2";
    };
  })

But just using gh and wslview maybe simple

@kachick
Copy link
Owner Author

kachick commented Sep 6, 2024

issue has been opened in upstream junegunn#40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to define WSL specific code in common Linux scripts?
1 participant