Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)

Related tags

Command-line is-wsl
Overview

is-wsl

Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)

Inspired by sindresorhus/is-wsl and made for Rust lang.

Can be useful if you need to work around unimplemented or buggy features in WSL. Supports both WSL 1 and WSL 2.

Usage

$> cargo add is-wsl

main.rs

use is_wsl::is_wsl

fn main() {
    if is_wsl() {
        // Do some WSL related stuff 🎇
    } else {
        // Do some different things! <3
    }
}
You might also like...
A super simple /sbin/init for Linux which allows running one and only one program

Summary High-performance /sbin/init program for Linux This is designed to do literally nothing but accept binaries over the network and run them as a

A library that allows for the arbitrary inspection and manipulation of the memory and code of a process on a Linux system.
A library that allows for the arbitrary inspection and manipulation of the memory and code of a process on a Linux system.

raminspect raminspect is a crate that allows for the inspection and manipulation of the memory and code of a running process on a Linux system. It pro

 rusty-donut - ASCII raymarching inside a terminal
rusty-donut - ASCII raymarching inside a terminal

ASCII raymarching inside a terminal

Shared execution environment for constructing 3D virtual spaces from the inside.

Hearth Hearth is a shared, always-on execution environment for constructing 3D virtual spaces from the inside. Come join our Discord server! The Histo

A tool to format codeblocks inside markdown and org documents.
A tool to format codeblocks inside markdown and org documents.

cbfmt (codeblock format) A tool to format codeblocks inside markdown, org, and restructuredtext documents. It iterates over all codeblocks, and format

Show HTML content
Show HTML content "inside" your egui rendered application

hframe Show HTML content "inside" your egui rendered application. "hframe" stands for "HTML Frame". Note: hframe only works when the application is co

A rustc plugin to check for numerical instability

Herbie lint for Rust What This plugin can add warnings or errors to your crate when using a numerically unstable floating point expression. Quick exam

languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments!
languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments!

languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments! Overview Install MacO

'apk-yara-checker' is a little CLI tool written in Rust to check Yara rules against a folder of APK files.
'apk-yara-checker' is a little CLI tool written in Rust to check Yara rules against a folder of APK files.

apk-yara-checker 'apk-yara-checker' is a little CLI tool written in Rust to check Yara rules against a folder of APK files. You have to pass the folde

Comments
  • Remove sys-info dependency

    Remove sys-info dependency

    Hi there,

    This PR removes the sys-info dependency, which is relatively large with a few dependencies of its own. Because we only use a tiny part of sys-info (the Linux part of os_release()), it's easy to "inline" what we need and avoid taking a dependency.

    I think this makes sense to keep compile times and binary size down, especially on non-Linux platforms where we don't need anything from sys-info. Let me know what you think!

    Licensing

    sys-info is MIT-licensed, so as I understand it this is OK because I've copied the copyright+permission notices verbatim. Doing so in source code comments seemed easiest.

    enhancement 
    opened by rgwood 4
  • Cache result with once_cell

    Cache result with once_cell

    Hello! Thanks for creating this crate; I spotted it in my GitHub feed and was quite happy because the older wsl crate has been abandoned. Hopefully is-wsl can be a nice replacement for wsl.

    If you're open to PRs, this PR caches the is_wsl() result with once_cell. It's similar to a PR I made for wsl, which was motivated by a situation in Nushell where we want to (frequently) check WSL status before rendering interactive content.

    I know it's not ideal to add a dependency, but once_cell is extremely widely used, so much so that it's already in std on nightly. Once it's stabilized, the external dependency will no longer be needed.

    I also added an example (cargo run --example main) just to make manual testing a bit easier.

    opened by rgwood 1
Releases(0.4.0)
  • 0.4.0(Jan 27, 2023)

    What's Changed

    • Remove sys-info dependency by @rgwood in https://github.com/TheLarkInn/is-wsl/pull/5

    Full Changelog: https://github.com/TheLarkInn/is-wsl/compare/0.3.0...0.4.0

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Jan 23, 2023)

    What's Changed

    • cargo clippy and update is-docker by @TheLarkInn in https://github.com/TheLarkInn/is-wsl/pull/4

    New Contributors

    • @TheLarkInn made their first contribution in https://github.com/TheLarkInn/is-wsl/pull/4

    Full Changelog: https://github.com/TheLarkInn/is-wsl/compare/0.2.0...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Jan 22, 2023)

    What's Changed

    • Cache result with once_cell by @rgwood in https://github.com/TheLarkInn/is-wsl/pull/1

    New Contributors

    • @rgwood made their first contribution in https://github.com/TheLarkInn/is-wsl/pull/1

    Full Changelog: https://github.com/TheLarkInn/is-wsl/commits/0.2.0

    Source code(tar.gz)
    Source code(zip)
Owner
Sean Larkin
Software Engineer @microsoft. Javascript, webpack, Typescript. @webpack core team. @angular cli core team. working on rushstack, heft, and OneDrive/SharePoint
Sean Larkin
Works out if this is running from inside a shell, and if so, which one.

pshell pshell answers the question "Is my application running in a shell, and if so, which one". Example: you are installing something and want to mak

Alec Brown 2 Nov 3, 2022
An implementation of a Windows Event Collector server running on GNU/Linux.

OpenWEC OpenWEC is a free and open source (GPLv3) implementation of a Windows Event Collector server running on GNU/Linux and written in Rust. OpenWEC

CEA IT Security 15 Jun 15, 2023
Check the reproducibility status of your Arch Linux packages (read-only mirror)

arch-repro-status A CLI tool for querying the reproducibility status of the Arch Linux packages using data from a rebuilderd instance such as reproduc

Arch Linux 12 Nov 16, 2022
Bashly - Bash CLI Framework and Generator

Bashly - Bash CLI Framework and Generator Create feature-rich bash scripts using simple YAML configuration

Danny Ben Shitrit 1.4k Jan 4, 2023
Nvm - Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Node Version Manager Table of Contents Intro About Installing and Updating Install & Update Script Additional Notes Troubleshooting on Linux Troublesh

nvm.sh 63.8k Jan 7, 2023
A handy way to handle sh/bash cli parameters

Argc A handy way to handle sh/bash cli parameters. How Argc works To write a command line program with Argc, we only need to do two things: Describe t

null 398 Jan 3, 2023
An enhanced history(1) for bash

history This is a replacement for the history builtin in bash. It has a couple of additional features that relative to the one included with bash: Con

Robert T. McGibbon 4 Aug 25, 2022
A `nix` and `nix-shell` wrapper for shells other than `bash`

nix-your-shell A nix and nix-shell wrapper for shells other than bash. nix develop and nix-shell use bash as the default shell, so nix-your-shell prin

Mercury 15 Apr 10, 2023
GPT-3 powered CLI tool to help you remember bash commands.

Rusty: GPT-3 Powered CLI Tool Convert natural language into executable commands directly from the terminal! Open source CLI tool powered by OpenAI (br

Zahid Khawaja 287 Apr 19, 2023
Simple joke randomizer from bash.org.pl made as CLI Tool in Rust.

RBashOrg Simple joke randomizer from bash.org.pl made as CLI Tool in Rust. Description Main motivation of this project was to learn basic concepts abo

Krzysztof Szostak 3 Feb 20, 2024