我想出了一个涵盖您问题的两个方面的解决方案
获得无限永久磁盘:
您可以使用 Google Cloud Storage FUSE
Google Cloud Storage FUSE 可让您将 GCS 存储桶作为文件夹挂载到您的 Linux 实例。通过这样做,您将获得一个“无限的”永久磁盘,并且设置起来非常简单,因为 gcsfuse 已经安装在 cloud shell 中。
1. Create a GCS bucket (you only need to run this once) -- replace BUCKET_NAME with any name:
gsutil mb "gs://BUCKET_NAME/"
2. Create a local directory for mounting -- replace FOLDER_NAME with the chosen directory name:
mkdir /home/[USER]/[FOLDER_NAME]
chmod 777 /home/[USER]/[FOLDER_NAME]
3. Mount the bucket onto the local filesystem (note: you need to re-run this every time Cloud Shell starts)
gcsfuse -o nonempty -file-mode=777 -dir-mode=777 --uid=1000 --debug_gcs [BUCKET_NAME] /home/[USER]/[FOLDER_NAME]
在 Cloud Shell 中使用第三方插件:
您可以使用public documentation 中提到的环境自定义脚本 (.customization_environment)。它允许您在启动时将其他软件包安装到 Cloud Shell 环境中。
作为参考,下面是安装VS Code插件的步骤。
第 1 步:
要安装 VSCode 服务器,请在 Cloud Shell Editor 的根目录工作区中运行名为 visual_studio_code.sh 的脚本,如下所示。
visual_studio_code.sh 文件:
export VERSION=`curl -s https://api.github.com/repos/cdr/code-server/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'`
wget https://github.com/cdr/code-server/releases/download/$VERSION/code-server-3.10.2-linux-amd64.tar.gz
tar -xvzf code-server-3.10.2-linux-amd64.tar.gz
cd code-server-3.10.2-linux-amd64
在 shell 中使用以下命令运行脚本,
./visual_studio_code.sh
if getting permission denied error then run this following command in shell,
chmod +x visual_studio_code.sh
./visual_studio_code.sh
第 2 步:
在 Cloud Shell Editor 的根目录工作区中创建一个自定义脚本,以便在启动时使用以下命令启动 VS Code Server:
.customization_environment 文件:
#!/bin/sh
#.customize_environmnet run in background as root, wait for your user to initialize
sleep 20
sudo -u [USER] /home/[USER]/code-server-3.10.2-linux-amd64/code-server --auth none --port 9090
第 3 步:
在端口 9090 上查看 Visual Studio Code 服务器:
Click on Web Preview > Change Port > 9090
如果收到 404 错误,请从 url 中删除“?authuser=0”。
Visual Studio Code Server 现在将在浏览器上运行!!!
块旅行导航插件:
要在cloud shell中拥有block travel navigation插件,请按照以下命令并在root目录下的shell中运行它们:
wget https://github.com/efatsi/block-travel/archive/refs/tags/v1.0.0.tar.gz
tar xzvf v1.0.0.tar.gz
ls
#You will see block-travel-1.0.0
block-travel-1.0.0/keymaps/block-travel.cson --auth none --port 9090
#You might get Permission denied if yes, then follow the next two commands else go to webport view in 9090
chmod +x block-travel-1.0.0/keymaps/block-travel.cson
block-travel-1.0.0/keymaps/block-travel.cson --auth none --port 9090
在 9090 中打开 webport 视图,您将能够使用以下命令浏览 vs 代码文件:
Alt+up for block-travel.jumpUp
Alt+shift+up for block-travel.selectUp
Alt+down for block-travel.jumpDown
Alt+shift+down for block-travel.selectDown