VS Code无法识别shebang为bash

时间:2020-08-09 13:50:08

标签: bash visual-studio-code vscode-settings shebang

根据此post,VS Code应该能够识别没有扩展名的文件中的shebang,并将这些文件与Shell脚本语言模式相关联。在那篇文章中,他们说它适用于shebang #!/bin/sh。但是,这似乎对shebang #!/bin/bash不起作用。我需要在项目中使用Bash,否则我将只切换到Shell命令语言(sh)。另外,我无法在文件名的末尾添加.sh扩展名,因为我正在向超级计算机提交批处理作业,并且文件名需要使用以下模式命名:jobname-batch。有没有一种方法可以将VS Code配置为对无扩展的Bash脚本具有与无扩展的Shell命令语言脚本相同的行为?

编辑:

@Julia在注释中建议使该文件可执行,然后使其生效。 :)谢谢!

1 个答案:

答案 0 :(得分:1)

“设置可执行位”设置有效,但是我不确定该信息存储在哪里或在重新启动后是否仍然存在。我只记得一个更好的解决方案:文件关联!

只需将其添加到[ { "certsname": "auth0.pem", "notBefore": "Apr 30 00:00:00 2020 GMT", "notAfter": "May 30 12:00:00 2021 GMT", "issuer": " /C=US/O=Amazon/OU=Server CA 1B/CN=Amazon", "subject": " /CN=auth0.com" }, { "certsname": "maximo.cer", "notBefore": "Feb 5 18:02:21 2020 GMT", "notAfter": "Apr 5 18:44:22 2021 GMT", "issuer": " /C=US/ST=Arizona/L=Scottsdale/O=Starfield Technologies, Inc./OU=http://certs.starfieldtech.com/repository//CN=Starfield Secure Certificate Authority - G2", "subject": " /OU=Domain Control Validated/CN=*.corp.amazon.com" }, { "certsname": "synovos.pem", "notBefore": "Aug 1 17:57:31 2020 GMT", "notAfter": "Aug 15 17:57:31 2020 GMT", "issuer": " /C=US/ST=California/O=Zscaler Inc./OU=Zscaler Inc./CN=Zscaler Intermediate Root CA (zscloud.net) (t)", "subject": " /OU=Domain Control Validated/CN=*.synovos.com" }, { "certsname": "veevavault.pem", "notBefore": "Jan 23 00:00:00 2018 GMT", "notAfter": "Jan 27 12:00:00 2021 GMT", "issuer": " /C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA", "subject": " /C=US/ST=California/L=Pleasanton/O=Veeva Systems, Inc./OU=Vault/CN=*.veevavault.com" } ] (密钥应为文件名):

project/.vscode/vscode.json