Skip to content

Instantly share code, notes, and snippets.

@mubaidr
Forked from davidlu1001/fix_vscode_copilot_cert.sh
Last active March 24, 2023 05:14
Show Gist options
  • Select an option

  • Save mubaidr/3f88bbe06d0ea1cea81e40c6f7ba44d1 to your computer and use it in GitHub Desktop.

Select an option

Save mubaidr/3f88bbe06d0ea1cea81e40c6f7ba44d1 to your computer and use it in GitHub Desktop.

Revisions

  1. mubaidr revised this gist Mar 24, 2023. 1 changed file with 15 additions and 3 deletions.
    18 changes: 15 additions & 3 deletions fix_vscode_copilot_cert.sh
    Original file line number Diff line number Diff line change
    @@ -2,12 +2,14 @@

    set -uo pipefail

    _VSCODEDIR="$HOME/.vscode/extensions"
    _COPILOTDIR=$(ls "${_VSCODEDIR}" | grep -E "github.copilot-[1-9].*" | sort -V | tail -n1) # For copilot
    _VSCODEDIR="$HOME/.vscode-insiders/extensions"
    _COPILOTDIR=$(ls "${_VSCODEDIR}" | grep -E "github.copilot-[1-9].*" | sort -V | tail -n1) # For copilot
    _COPILOTDEVDIR=$(ls "${_VSCODEDIR}" | grep "github.copilot-nightly-" | sort -V | tail -n1) # For copilot-nightly
    _COPILOTLABSDIR=$(ls "${_VSCODEDIR}" | grep "github.copilot-labs-" | sort -V | tail -n1) # For gitHub.copilot-labs

    _EXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDIR}/dist/extension.js"
    _DEVEXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDEVDIR}/dist/extension.js"
    _DEVLABSEXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTLABSDIR}/dist/extension.js"

    if [[ -f "$_EXTENSIONFILEPATH" ]]; then
    echo "Found Copilot Extension, applying 'rejectUnauthorized' patches to '$_EXTENSIONFILEPATH'..."
    @@ -23,4 +25,14 @@ if [[ -f "$_DEVEXTENSIONFILEPATH" ]]; then
    sed -i.bak 's/d={...l,/d={...l,rejectUnauthorized:false,/g' ${_DEVEXTENSIONFILEPATH}
    else
    echo "Couldn't find the extension.js file for Copilot-Nightly, please verify paths and try again or ignore if you don't have Copilot-Nightly..."
    fi
    fi

    if [[ -f "$_DEVLABSEXTENSIONFILEPATH" ]]; then
    echo "Found gitHub.copilot-labs Extension, applying 'rejectUnauthorized' patches to '$_DEVLABSEXTENSIONFILEPATH'..."
    perl -pi -e 's/,rejectUnauthorized:[a-z]}(?!})/,rejectUnauthorized:false}/g' ${_DEVLABSEXTENSIONFILEPATH}
    sed -i.bak 's/d={...l,/d={...l,rejectUnauthorized:false,/g' ${_DEVLABSEXTENSIONFILEPATH}
    else
    echo "Couldn't find the extension.js file for gitHub.copilot-labs, please verify paths and try again or ignore if you don't have gitHub.copilot-labs..."
    fi

    read -p "Press Enter to continue" </dev/tty
  2. @davidlu1001 davidlu1001 created this gist Mar 13, 2022.
    26 changes: 26 additions & 0 deletions fix_vscode_copilot_cert.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/usr/bin/env bash

    set -uo pipefail

    _VSCODEDIR="$HOME/.vscode/extensions"
    _COPILOTDIR=$(ls "${_VSCODEDIR}" | grep -E "github.copilot-[1-9].*" | sort -V | tail -n1) # For copilot
    _COPILOTDEVDIR=$(ls "${_VSCODEDIR}" | grep "github.copilot-nightly-" | sort -V | tail -n1) # For copilot-nightly

    _EXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDIR}/dist/extension.js"
    _DEVEXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDEVDIR}/dist/extension.js"

    if [[ -f "$_EXTENSIONFILEPATH" ]]; then
    echo "Found Copilot Extension, applying 'rejectUnauthorized' patches to '$_EXTENSIONFILEPATH'..."
    perl -pi -e 's/,rejectUnauthorized:[a-z]}(?!})/,rejectUnauthorized:false}/g' ${_EXTENSIONFILEPATH}
    sed -i.bak 's/d={...l,/d={...l,rejectUnauthorized:false,/g' ${_EXTENSIONFILEPATH}
    else
    echo "Couldn't find the extension.js file for Copilot, please verify paths and try again or ignore if you don't have Copilot..."
    fi

    if [[ -f "$_DEVEXTENSIONFILEPATH" ]]; then
    echo "Found Copilot-Nightly Extension, applying 'rejectUnauthorized' patches to '$_DEVEXTENSIONFILEPATH'..."
    perl -pi -e 's/,rejectUnauthorized:[a-z]}(?!})/,rejectUnauthorized:false}/g' ${_DEVEXTENSIONFILEPATH}
    sed -i.bak 's/d={...l,/d={...l,rejectUnauthorized:false,/g' ${_DEVEXTENSIONFILEPATH}
    else
    echo "Couldn't find the extension.js file for Copilot-Nightly, please verify paths and try again or ignore if you don't have Copilot-Nightly..."
    fi