1
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 1 year has passed since last update.

.vscode/tasks.json で ~/.bashrc が読み込まれない

Last updated at Posted at 2023-12-20

状況

  • 理由はよくわからない。
  • ChatGPT に導かれるままに ~/.bash_profile に書いたら動いた。
  • なぜかわからない。
  • source /home/user/.bashrc をいれても改善しない。
  • ~/.bashrc~/.bash_profile の違いを調べても原因が理解できない

今回の事象と関連すると思われる何かかが議論されているけどわかりませんでした...

環境変数を使う方法

1. ~/.bash_profile に書き込む

~/.bash_profile
YOUR_WEBSITE_URL=http://localhost:8000
tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      // 立ち上がりが激重のため...
      "label": "chrome",
      "type": "shell",
      // connection refused を防ぐために sleep, curl する
      "command": "echo ${YOUR_WEBSITE_URL} && sleep 7 && curl ${YOUR_WEBSITE_URL}/page-title && google-chrome ${YOUR_WEBSITE_URL}/page-title && exit",
      "presentation": {
        "close": true
      }
    }
  ]
}

2. options.env に書き込む

YOUR_WEBSITE_URL が長かったので短くしました...

tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      // 立ち上がりが激重のため...
      "label": "chrome",
      "type": "shell",
      // connection refused を防ぐために sleep, curl する
      "command": "echo ${URL} && sleep 7 && curl ${URL}/page-title && google-chrome ${URL}/page-title && exit",
      "presentation": {
        "close": true
      },
      "options": {
        "env": {
          // NG: env が必要
          // "URL": "${YOUR_WEBSITE_URL}"
          // OK:
          "URL": "${env:YOUR_WEBSITE_URL}"
        }
      }
    }
  ]
}

参考

tasks.json で使う変数に関することが書かれています。

1
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
1
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?