Allow use of Environment variables in languages.toml (and/or config.toml) #12851
-
It would be cool if I could do: [[language]]
name = "markdown"
formatter = { command = "pwsh", args = ["-noprofile", "-f", "${env:PS_SCRIPTS}\\format_md.ps1"]}
auto-format = true Where |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I am always a little bit nervous when config files can evaluate code from an environment variable. That can lead to potential security problems later on. Out of curriosity, what would you use that feature for? |
Beta Was this translation helpful? Give feedback.
-
I would say that in this case, it is only evaluating the environment variable, nothing more.
It just makes the config files easier to edit, especially the |
Beta Was this translation helpful? Give feedback.
-
I believe this should already be possible if you provide a formatter that executes a shell command. For example on linux: [[language]]
name = "markdown"
auto-format = true
formatter = { command = "sh", args = ["-c", "echo $PWD"] } |
Beta Was this translation helpful? Give feedback.
-
@the-mikedavis yes, thank you for the solution. It is dependent on the shell you are targeting. With [[language]]
name = "markdown"
formatter = { command = "pwsh", args = ["-noprofile", "-c", ".", "$env:PS_SCRIPTS\\format_md.ps1"]}
auto-format = true
I hereby mark this as solved. |
Beta Was this translation helpful? Give feedback.
@the-mikedavis yes, thank you for the solution. It is dependent on the shell you are targeting. With
pwsh
, you have to use-c
flag (for command) to run a file:. <script path>.ps1
is PowerShell's syntax of executing a script, that is why you have.
as the first argument to-c
.I hereby mark this as solved.