在 VS Code 任务中使用 .bash_profile 函数

RWDJ

我在 VS Code 中定义了以下任务:

"label": "build",
"type": "shell",
"command": "opengl++ Interpolate.cpp"

opengl++()定义的 bash 函数在哪里~/.bash_profile我正在使用 MacOS High Sierra,该功能在Terminal.app 中有效执行这个任务得到:

> 执行任务:opengl++ Interpolate.cpp <

/bin/bash: opengl++: command not found
终端进程以退出代码终止:127

将任务更改为:

"label": "build",
"type": "shell",
"command": "source ~/.bash_profile && opengl++ Interpolate.cpp"

解决了这个问题,这使得终端似乎没有正确采购。我尝试删除 VS Code 上的所有用户设置无济于事。

这不是一个可行的解决办法。要求明确采购似乎很危险~/.bash_profile在使用 python (pyenv) 和类似编译器的构建任务时,这似乎可能会导致问题,这些编译器~/.bash_profile用于正确编译而忘记显式源代码。

如何使用定义的函数~/.bash_profile在 VS Code shell 任务中工作而不预先添加source ~/.bash_profile

RWDJ

.vscode. 该脚本可以包含有组织且复杂的命令。然后,使用类似于以下命令的任务在任务中获取脚本:

source .vscode/scripts/build.sh

般的线条set -esource ~/.bash_profile除其他事项外,可以包含在脚本,我们有一个更干净tasks.json

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Win10:VS Code集成bash无法加载〜/ .bash_profile

如何注册调用函数的VS Code任务

从.bash_profile加载.profile还是根本不使用bash_profile?

如何使用Python打开“〜/ .bash_profile”

使用python运行bash_profile命令

在jupyter笔记本中使用bash_profile别名

在VS Code和virtualenv中使用Azure函数时找不到Numpy模块

在 VS Code 中使用 virtualenv

使用 .bash_profile 和 .bashrc 作为一个

为什么`source`与virtualenvwrapper一起在.bash_profile中使用?

如何在.bash_profile中使用别名创建简单路径(Mac)

在bash_profile中创建函数时export -f语句的作用

您可以通过管道传输到.bash_profile函数吗?

在交互式shell中找不到〜/ .bash_profile中的函数

.bash_profile函数在同一文件目录上运行操作

在VS Code中使用IPython REPL

如何在VS Code中使用TSLint?

无法在VS Code中使用外部jar

在WSL Ubuntu中使用Chocolatey VS Code

在VS Code中的TypeScript中使用jQuery

Anaconda无法在VS Code中使用

VS Code 任务 2.0 问题

VS代码:使用WSL / Bash运行任务

在 VS Code 中使用 Git Bash 终端 - 如何强制它在内部打开

在VS Code中使用Git Bash终端-如何强制其在内部打开

如何在VS Code中使用Windows的内置OpenSSH ssh-agent,而不是Git bash?

如何从其他文件夹使用.bash_profile加载Bash

在终端会话中激活别名而不使用 bashrc 或 bash_profile 或 bash_aliases?

开始使用git bash,这些行在.bash_profile中是什么意思?