0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Bash] Visual Studio Codeにインストールしている全拡張機能をMarkdown出力するシェルスクリプト

Last updated at Posted at 2021-11-02

動機

vscodeの機能拡張は--list-extensionsオプションで一覧出力できます。

% code --list-extensions
AzureADB2CTools.aadb2c
bencoleman.armview
bmewburn.vscode-intelephense-client
esbenp.prettier-vscode
formulahendry.dotnet-test-explorer
GitHub.remotehub
k--kato.docomment

機械的には十分なのですが、人間的にはどれがなんだかわからないので、Visual Studio Marketplaceに問い合わせて、見やすい名前を出力するようにしました。

完成品の結果

こんな感じに出力されます。

% ./list-code-extensions.sh                                                                                                                                   
# Azure AD B2C
https://marketplace.visualstudio.com/items?itemName=AzureADB2CTools.aadb2c

Azure AD B2C custom policy extension


# ARM Template Viewer
https://marketplace.visualstudio.com/items?itemName=bencoleman.armview

Graphically display ARM templates in an interactive map view

                                                                                              

Qiitaへ貼るとこんなんです。

# ヘッダのあとに改行入れずにURL書くと、OGPが展開されるんですね。便利。

作ったもの

curlとjq呼んでいるだけなのです。

# !/bin/bash

set -eu

generate_request()
{
    cat << EOT
{"assetTypes":null,"filters":[{"criteria":[{"filterType":7,"value":"${1}"}],"direction":2,"pageSize":100,"pageNumber":1,"sortBy":0,"sortOrder":0,"pagingToken":null}],"flags":103}
EOT
}

query_market()
{
    curl -s \
        -H "Content-Type: application/json" \
        -H "Accept: application/json;api-version=6.1-preview.1;excludeUrls=true" \
        -X POST \
        --data "$(generate_request $1)" \
        "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery"
}

make_pretty()
{
    query_market "$1" \
    | jq -r '.results[0] | .extensions[0] | .displayName,.shortDescription'
}

main()
{
    local IFS=$'\n' GLOBIGNORE=\*

    env code --list-extensions | while read id
    do
        desc=($(make_pretty "${id}"))

        echo \# ${desc[0]//#/\\# }
        echo "https://marketplace.visualstudio.com/items?itemName=${id}"
        echo
        echo ${desc[1]}
        echo
        echo
    done
}

main

使い方

適当な名前(例えば、list-code-extensions.sh)で保存し、実行属性をつけて実行してください。

./list-code-extensions.sh
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?