Code.ps1


function Install-CodeExtension {
  param (
    [string] $Name
  )

  $extensions = code --list-extensions
  if (-Not($extensions -Contains $Name)) {
    code --install-extension $Name
  }
}

function Start-Code {

  param(
    [switch] $Browser
  )

  if ($Browser) {
    Start-Process "https://vscode.dev/"
    return
    # [system.Diagnostics.Process]::Start("msedge","https://debug.to") chrome firefox
    #"Look instructions at https://xtec.dev/dev/vscode/remote/"
  }

  if (-Not(Get-Command "git" -ErrorAction SilentlyContinue)) {
    Install-Scoop 
    scoop install git # Git is required for buckets.
    # TODO add user name, email
  }

  if (-Not(Get-Command "code" -ErrorAction SilentlyContinue)) {
    Install-Scoop
    scoop bucket add extras
    scoop install vscode
  }

  # add image shortcut on desktop

  Install-CodeExtension "ms-vscode-remote.remote-ssh"
  Install-CodeExtension "ms-vscode-remote.remote-wsl"
  Install-CodeExtension "ms-vscode.remote-server"

  code

}