Skip to content

Instantly share code, notes, and snippets.

@benburrill
Created February 15, 2023 05:15
Show Gist options
  • Save benburrill/ad574a18dae9f9b92ff7421ebc5f3013 to your computer and use it in GitHub Desktop.
Save benburrill/ad574a18dae9f9b92ff7421ebc5f3013 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Works around exes taking 10 seconds to start in the WSL if launched
# with a PWD that is in the linux filesystem.
old_pwd="$PWD"
# The <CommandParameters> seem to get concatenated together if you pass
# them to powershell, and I can't easily get proper escaping to work, so
# I'm just wrapping things in ' so it will at least you can have spaces.
cd /mnt/c && exec 'powershell.exe' '-Command' "Start-Process -WorkingDirectory$(printf " '%s'" "$(wslpath -w "$old_pwd")")$(printf " '%s'" "$@")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment