Skip to content
/ wsl-open Public

A Go utility for WSL to open files, directories, and URLs in their default Windows applications.

License

Notifications You must be signed in to change notification settings

jbwfu/wsl-open

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wsl-open

Go Report Card Build Status Latest release License: MIT

简体中文

A simple, fast, and robust utility to open files, directories, and URLs from WSL in their default Windows applications.

Features

  • Fast & Lightweight: Starts instantly as a compiled native binary with no shell overhead.
  • Safe & Robust: Correctly handles complex paths with spaces and special characters. Uses a sanitized command execution method to prevent shell injection vulnerabilities.
  • Simple & Focused: Does one thing and does it well. The command-line interface is minimal and intuitive.
  • Works Out-of-the-Box: Requires no extra libraries or runtimes to install. It works on any modern WSL2 environment by leveraging its built-in tools.

Installation

The recommended way is to download the latest binary from the Releases page.

# Replace vX.Y.Z with the latest version number, for example: v1.0.0
wget https://github.com/jbwfu/wsl-open/releases/download/vX.Y.Z/wsl-open_linux_amd64.tar.gz
tar -xvf wsl-open_linux_amd64.tar.gz
sudo mv wsl-open /usr/local/bin/
Other Installation Methods

With go install:

go install github.com/jbwfu/wsl-open@latest

From Source:

git clone https://github.com/jbwfu/wsl-open.git
cd wsl-open
go build
sudo mv wsl-open /usr/local/bin/

Usage

Provide a path to a file, a directory, or a URL as an argument.

A Note on WSL1 Support

This tool is fully optimized for WSL2. Due to fundamental differences in filesystem architecture, support for opening files and directories on WSL1 is limited.

  • Opening URLs works on both WSL1 and WSL2.
  • Opening files/directories on Windows drives (e.g., /mnt/c/...) works on both.
  • Opening files/directories from the native Linux filesystem (e.g., ~/file.txt) is only reliably supported on WSL2.

There are no plans to add specific workarounds for WSL1. It is highly recommended to use WSL2 for the best experience.

# Open a file in its default Windows application
wsl-open "My Documents/report.docx"

# Open the current directory in Windows File Explorer
wsl-open .

# Open a URL in the default Windows browser
wsl-open https://github.com

Use the -x flag to see what command would be executed without running it. For more details, run wsl-open --help.

Pro Tip: Use as a Fallback for xdg-open

For minimal WSL environments that may not include xdg-open, you can link wsl-open to act as a system-wide default. This allows tools that call xdg-open (like git browse) to work seamlessly.

First, check if xdg-open is already installed:

command -v xdg-open

If the command above returns no output, you can create a symbolic link:

# This finds where wsl-open is and links it to /usr/local/bin/xdg-open
sudo ln -s "$(command -v wsl-open)" /usr/local/bin/xdg-open

TODO

  • Full xdg-open integration.
  • Native path translation (remove wslpath dependency).

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

About

A Go utility for WSL to open files, directories, and URLs in their default Windows applications.

Topics

Resources

License

Stars

Watchers

Forks

Languages