vscode使用

1 vscode remote 问题

1.1 远程服务器中安装vscode插件速度缓慢

  • 问题描述:vscode远程连接到云服务器进程操作时,如果需要使用vscode拓展插件的功能,必须要把vscode插件安装到云服务器上(vscode为ssh主机、容器或WSL安装插件时,将使用 Marketplace 版本而不是已经安装在本地计算机上的插件版本)。而我经常遇到本地安装插件很方便,但远程服务器上插件安装不上或者速度很慢的问题
  • 解法方案:

1、可以到 vscode插件市场 下载插件(.vsix文件)到本地,然后把插件上传到服务器指定目录,最后在vscode中安装远程服务器上的已下载好的插件。
2、也可以通过curl直接把把.vsix文件直接下载到服务器,然后在vscode拓展界面中选择最上角三点,选择“从vsix形式安装”来安装插件。

#!/bin/bash

# ↓↓↓↓↓ 定义通用变量  ↓↓↓↓↓ 

# 定义vscode插件存放目录
targetDir="/root/.vscode-server/extensions"
# 定义请求cookie。如果没有该cookie,网站将拒绝插件下载请求,并提示 “Request was blocked due to exceeding usage of resource 'Count' in namespace 'AnonymousId'”。
# 这些cookie是通过访问https://marketplace.visualstudio.com/vscode 获得的。
requestCookiesValue="VstsSession=%7B%22PersistentSessionId%22%3A%229502a0c3-81b9-40d6-bef2-7576483543ac%22%2C%22PendingAuthenticationSessionId%22%3A%2200000000-0000-0000-0000-000000000000%22%2C%22CurrentAuthenticationSessionId%22%3A%2200000000-0000-0000-0000-000000000000%22%2C%22SignInState%22%3A%7B%7D%7D; Gallery-Service-UserIdentifier=bbc415e5-86d8-4a90-836c-2fa21892855b; _ga=GA1.3.1030456683.1687422167; _gid=GA1.3.835449727.1687422167; _gat_UA-62780441-6=1; Market_SelectedTab=vscode"
# ↑↑↑↑↑ 定义通用变量  ↑↑↑↑↑

sudo mkdir -p ${targetDir} # vscode插件存放位置。下载前先确保该目录存在

# 以下是可以套用的模板。想下载什么插件,去vscode插件市场搜索,然后在下载按钮处右键复制下载地址,把模板的网址替换成插件下载地址即可 #
# 2023.6.21 下载Bash IDE插件  版本选择地址 https://marketplace.visualstudio.com/items?itemName=mads-hartmann.bash-ide-vscode
curl -o ${targetDir}/Bash-IDE.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/mads-hartmann/vsextensions/bash-ide-vscode/1.37.0/vspackage' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

# 2023.6.21 下载ShellCheck插件  版本选择地址 https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck
curl -o ${targetDir}/ShellCheck.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/timonwong/vsextensions/shellcheck/0.32.6/vspackage?targetPlatform=linux-x64' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

# 2023.6.22 下载 Shell script command completion插件 版本选择地址 https://marketplace.visualstudio.com/items?itemName=tetradresearch.vscode-h2o
curl -o ${targetDir}/Shell-script-command-completion.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/tetradresearch/vsextensions/vscode-h2o/0.2.9/vspackage' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

# 2023.6.22 下载Banner comments插件 版本选择地址 https://marketplace.visualstudio.com/items?itemName=heyimfuzz.banner-comments
curl -o ${targetDir}/Banner-comments.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/heyimfuzz/vsextensions/banner-comments/0.4.3/vspackage' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

# 2023.6.22 下载Syntax Highlighter插件 版本选择地址 https://marketplace.visualstudio.com/items?itemName=evgeniypeshkov.syntax-highlighter
curl -o ${targetDir}/Syntax-Highlighter.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/evgeniypeshkov/vsextensions/syntax-highlighter/0.5.0/vspackage' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

# 2023.6.22 下载Shell Syntax插件 版本选择地址 https://marketplace.visualstudio.com/items?itemName=bmalehorn.shell-syntax&ssr=false#version-history
curl -o ${targetDir}/Shell-Syntax.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/bmalehorn/vsextensions/shell-syntax/1.0.5/vspackage' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

# 2023.6.22 下载Docker插件 版本选择地址 https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
curl -o ${targetDir}/Docker.vsix 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-azuretools/vsextensions/vscode-docker/1.25.1/vspackage' \
  -H "cookie: ${requestCookiesValue}" \
  --compressed

2 其他待补充

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值