WSL2 内から起動するブラウザを Windows 側のブラウザにする方法($ gh repo view --web 時などで)

結論

環境変数 BROWSER に Windows のブラウザの場所を指定する。

具体例

例えば Chrome の場合は以下のように指定します*1

BROWSER="/mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe"

参考

github.com

補足

gh だけのスコープとしたいならば、$ gh config を用いてもよいです。

$ gh config
Display or change configuration settings for gh.

Current respected settings:
- git_protocol: the protocol to use for git clone and push operations (default: "https")
- editor: the text editor program to use for authoring text
- prompt: toggle interactive prompting in the terminal (default: "enabled")
- pager: the terminal pager program to send standard output to
- http_unix_socket: the path to a unix socket through which to make HTTP connection
- browser: the web browser to use for opening URLs


USAGE
  gh config <command> [flags]

CORE COMMANDS
  get:        Print the value of a given configuration key
  list:       Print a list of configuration keys and values
  set:        Update configuration with a value for the given key

INHERITED FLAGS
  --help   Show help for command

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual
$ gh config list
git_protocol=https
editor=
prompt=enabled
pager=
http_unix_socket=
browser=

*1:インストール場所が異なっていたり他のブラウザを使いたい場合には、それぞれの場所を指定して下さい

Powered by はてなブログ