Skip to content
opustecnica edited this page Nov 22, 2022 · 9 revisions

Portable Mode

Here's the desired outcome on Windows:

|- VSCode-win32-x64-1.25.0-insider
|   |- Code.exe (or code executable)
|   |- data
|   |   |- user-data
|   |   |   |- ...
|   |   |- extensions
|   |   |   |- ...
|   |- ...

If you want ctrl+` to toggle back and forth, add this to your keybindings.json:

{ "key": "ctrl+`",          "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" },
{ "key": "ctrl+`",          "command": "workbench.action.terminal.focus", "when": "!terminalFocus" },
// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "ctrl+shift+1",
        "command": "PowerShell.ShowSessionConsole"
    },
    {
        "key": "ctrl+shift+r",
        "command": "workbench.action.toggleMaximizedPanel"
    },
    {
        "key": "ctrl+]",
        "command": "workbench.action.focusSideBar"
    },
    {
        "key": "ctrl+0",
        "command": "workbench.action.zoomReset"
    },
    {
        "key": "ctrl+numpad0",
        "command": "-workbench.action.zoomReset"
    },
    // Toggle between terminal and editor focus
    {
        "key": "ctrl+D",
        "command": "workbench.action.terminal.focus"
    },
    {
        "key": "ctrl+D",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "terminalFocus"
    },
    {
        "key": "ctrl+j",
        "command": "editor.action.insertSnippet"
    },
    { 
        "key": "ctrl+shift+x", 
        "command": "workbench.action.terminal.kill" 
    },
    { 
        "key": "ctrl+shift+j", 
        "command": "workbench.action.terminal.focusNext" 
    },
    { 
        "key": "ctrl+shift+k", 
        "command": "workbench.action.terminal.focusPrevious" 
    },
    {
        "key": "ctrl+shift+q",
        "command": "workbench.action.toggleMaximizedPanel"
    },
    {
        "key":"ctrl+f6",
        "command": "PowerShell.InvokeRegisteredEditorCommand",
        "args" : {"commandName": "Insert.ToDo"},
        "when": "editorTextFocus"
    }
]

Change Terminals

{ "key": "cmd+shift+left", "command": "workbench.action.terminal.focusNext" },
{ "key": "cmd+shift+right", "command": "workbench.action.terminal.focusPrevious" }

Settings.json

{
    "remote.SSH.configFile": "H:\\.ssh\\config",
    "remote.SSH.localServerDownload": "auto",
    "remote.SSH.showLoginTerminal": true,
    "remote.SSH.enableX11Forwarding": false,
    "remote.SSH.useLocalServer": false,
    "remote.SSH.useFlock": false,
    "remote.SSH.enableDynamicForwarding": true,
    "remote.SSH.logLevel": "debug",
    "security.workspace.trust.untrustedFiles": "open",
    "vscode-edge-devtools.mirrorEdits": true,
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "debug.console.fontSize": 14,

    "telemetry.telemetryLevel": "off",
    "files.defaultLanguage": "powershell",
    "git.ignoreMissingGitWarning": true,
    "extensions.autoUpdate": false,
    "editor.accessibilitySupport": "off",
    "editor.minimap.enabled": false,
    "editor.formatOnPaste": true,
    "editor.formatOnType": true,
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "ms-vscode.powershell-preview",
    "editor.cursorWidth": 2,
    "editor.snippetSuggestions": "bottom",
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.tabCompletion": "on",
    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs":"active",
    "editor.suggestSelection": "first",
    "editor.fontSize": 13,

    "terminal.integrated.profiles.windows": {
        "Pwsh 7.2.6": {
            "path": [
                "H:\\PowerShell-7.2.6-win-x64\\pwsh.exe"
            ],
            "args": [],
            "icon": "terminal-powershell"
        },
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },
        "GitBash": {
            "source": "Git Bash"
        }
    },
    "terminal.integrated.defaultProfile.windows": "Pwsh 7.2.6",    
    "terminal.integrated.shell.windows": "H:\\PowerShell-7.2.6-win-x64\\pwsh.exe",
    "terminal.integrated.scrollback": 1000,
    "terminal.integrated.cursorStyle": "line",
    "terminal.integrated.allowChords": false,
    "terminal.integrated.drawBoldTextInBrightColors": false,
    // "terminal.integrated.experimentalLinkProvider": false,
    "terminal.integrated.cursorBlinking": true,
    "terminal.integrated.cursorWidth": 2,
    "terminal.integrated.persistentSessionReviveProcess": "never",
    "terminal.integrated.fontSize": 14,
    "terminal.integrated.copyOnSelection": true,
/*
    "powershell.powerShellAdditionalExePaths": [
        {
            "versionName": "Pwsh 7.2.6",
            "exePath": "H:\\PowerShell-7.2.6-win-x64\\pwsh.exe"
        }
    
    ],
*/
    "powershell.powerShellAdditionalExePaths": {
            "Pwsh 7.2.6": "H:\\PowerShell-7.2.6-win-x64\\pwsh.exe"
    },
    "powershell.powerShellDefaultVersion": "Pwsh 7.2.6",

    "powershell.integratedConsole.suppressStartupBanner": false,
    // "powershell.promptToUpdatePackageManagement": false,
    "powershell.codeFormatting.trimWhitespaceAroundPipe": true,
    "powershell.codeFormatting.whitespaceBetweenParameters": true,
    "powershell.integratedConsole.showOnStartup": true,
    "powershell.scriptAnalysis.enable": true,
    "powershell.codeFormatting.useCorrectCasing": true,
    "powershell.codeFormatting.useConstantStrings": true,
    "powershell.integratedConsole.useLegacyReadLine": false,
    "powershell.buttons.showPanelMovementButtons": true,
    "powershell.codeFormatting.autoCorrectAliases": true,
    "powershell.codeFormatting.preset": "OTBS",
    "powershell.startAsLoginShell.osx": false,
    "powershell.codeFormatting.addWhitespaceAroundPipe": false,
  
    "workbench.startupEditor": "newUntitledFile",
    "workbench.colorCustomizations": {
        "terminal.ansiBlack": "#0C0C0C",
        "terminal.ansiBlue": "#0037DA",
        "terminal.ansiBrightBlack": "#767676",
        "terminal.ansiBrightBlue": "#3B78FF",
        "terminal.ansiBrightCyan": "#61D6D6",
        "terminal.ansiBrightGreen": "#61D6D6",
        "terminal.ansiBrightMagenta": "#3B78FF",
        //"terminal.ansiBrightRed": "#f14c4c",
        "terminal.ansiBrightRed": "#E74856",
        "terminal.ansiBrightWhite": "#F2F2F2",
        //"terminal.ansiBrightYellow": "#f5f543",
        "terminal.ansiBrightYellow":"#F9F1A5",
        "terminal.ansiCyan": "#3A96DD",
        "terminal.ansiGreen": "#13A10E",
        "terminal.ansiMagenta": "#881798",
        //"terminal.ansiRed": "#cd3131",
        "terminal.ansiRed":"#C50F1F",
        "terminal.ansiWhite": "#CCCCCC",
        //"terminal.ansiYellow": "#e5e510"
        "terminal.ansiYellow":"#FFFFB6"
    },
    "update.enableWindowsBackgroundUpdates": false,
    "update.mode": "manual",
    "window.zoomLevel": -1,
}

Offline Mode

Below settings can be currently used to enter an offline mode

{
    "telemetry.enableTelemetry": false
    "telemetry.enableCrashReporter": false
    "update.channel": "none"
    "extensions.autoupdate": false
    "extensions.showRecommendationsOnlyOnDemand": true
    "update.showReleaseNotes": false
    "workbench.settings.enableNaturalLanguageSearch": false
    "editor.accessabilitySupport": "off"
}

Enable native bracket matching:

{
    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs":"active"
}

Microsoft.VSCode_profile.ps1

# HELP: shift + alt + S to get a list of available registered functions.
# REF: https://jdhitsolutions.com/blog/powershell/5907/extending-vscode-with-powershell/
# REF: https://github.com/PowerShell/PowerShellEditorServices/blob/master/docs/guide/extensions.md

Write-Verbose 'Defining VSCode additions'
$ScriptBlock = {
    Param( $Context )
    $WShell = New-Object -ComObject wscript.shell
    # $WShell.SendKeys('^d')
    $WShell.SendKeys('+^1')
    Write-Host ''
    do {
        Write-Host '[1] TODO - [2] NOTE - [3] DEBUG'
        $Selection = Read-Host 'Please make a selection'
        $Prompt = switch ($selection) {
            '1' { 'TODO' } 
            '2' { 'NOTE' } 
            '3' { 'DEBUG' } 
        }
    }
    until ($Selection -in 1..3)
    $Item = Read-Host -Prompt $Prompt
    $WShell.SendKeys('^d')
    $Todo = "# [$(Get-Date -Format 'MMM dd HH:mm:ss')] ${Prompt}: $Item [JR]"
    $Context.CurrentFile.InsertText($Todo)
}
$RegistrationParameters = @{
    Name           = 'Insert.ToDo'
    DisplayName    = 'Insert ToDo'
    ScriptBlock    = $ScriptBlock
    SuppressOutput = $false
}
Register-EditorCommand @RegistrationParameters
#endregion Register VSCODE functions

Links

Performance-Issues