WSL: Firefox for Golang default browser

I used a tool called aws-okta. It’s implemented in Go language. ‘login’ command will open generated URL in browser.

Environments where aws-okta login and aws-okta exec are known to work include:


aws-okta/ at master · segmentio/aws-okta

The page above doesn’t say WSL as one of known to work env.

Indeed, it didn’t work. It complained about ‘xdg-open’ not found. I didn’t want to install this tool. This tool doesn’t have much value for WSL users. WSL has it’s own similar tool , for example wslstart, which will open specified file in appropriate Windows native app.

So, I searched alternative. Sadly, Go standard library doesn’t seem to read any environment variable for alternative browser(e.g. Firefox,Chrome)  as the thread below shows.

there’s OS-specific ways to open things in a browser

cmd/internal/browser: Open() shouldn’t rely on Commands() · Issue #33148 · golang/go

So, I installed xdg-open with ‘sudo apt install’ .  This is not the end of the story. I ended up using 2 environment variables like below.

$ sudo \
  PATH="$PATH:/mnt/c/Program Files/Mozilla Firefox" \
  BROWSER=firefox.exe \
  ~/go/bin/aws-okta login my_profile
[sudo] password for myWSLusername:
Enter passphrase to unlock /home/myWSLusername/.aws-okta/:
INFO[0006] Requesting MFA. Please complete two-factor authentication with your second device
INFO[0006] Select a MFA from the following list
INFO[0006] 0: OKTA (token:software:totp)
INFO[0006] 1: OKTA (push)
Select MFA method: 0

Enter MFA Code: abcdxxxxxxx

There’s related discussion below. But I don’t think the thread covers all solutions for various kinds of envs.

You can set the BROWSER variable.

bash – Open browser in host system from Windows Subsystem for Linux? – Super User

Hope this helps some Windows mate!

Another workaround is to have aws-okta to spit out the generated URL on stdout.

Windows Terminal/WSL:Git対応prompt試してみた


WSL==Ubuntu-18.04です。”colorScheme”: “Solarized Dark” で/mnt/c以下の git ディレクトリーと ~kinoue 以下のgitディレクトリーでいくつか操作した時の画面が以下です。コマンドプロンプトが派手になりました!


.git のあるディレクトリーにファイル追加すると追加されたファイル数が赤よりの臙脂色で表示されたり、直前のコマンドのステータスが 0 でない場合、magenta (マゼンタ、マジェンタ、赤とピンクの中間)に変わることが確認できました。bash変数 “$?” が0かどうかを見てるんでしょうか。

if your source is under /mnt/c or /mnt anywhere, the git calls being made to populate the prompt are super slow.

How to make a pretty prompt in Windows Terminal with Powerline, Nerd Fonts, Cascadia Code, WSL, and oh-my-posh – Scott Hanselman

上のMicrosoft の有名人 Hanselman 氏の記事を参考にしました。

ところで引用部分にも書いてあるように WSL1 では C: , D: などのいわゆるドライブ文字を /mnt/c/ , /mnt/d/ にマウントしてる場合でのファイル操作は(特に git ??) は遅いそうですね。これは結構目から鱗でした。