简体   繁体   English

更漂亮的 shell 脚本格式

[英]Prettier shell script format

Can I format template literal embedded shell script with Prettier?我可以用 Prettier 格式化嵌入的模板文字 shell 脚本吗?

Example:例子:

Before formating:格式化前:

import {bash} from 'random-bash-runner'

await bash`
a_bash_command argument1 \
     main-dev \
argument4 --database=name --quiet`

After formatting:格式化后:

import {bash} from 'random-bash-runner'

await bash`
  a_bash_command argument1 \
    main-dev \
    argument4 l \
    --database=name --quiet
`

Thanks谢谢

Prettier can, with the setting --embedded-language-formatting=auto (see here ), format templates. Prettier 可以通过设置--embedded-language-formatting=auto (参见此处)格式化模板。

However, the languages it can format (from it's extension page on VSCode) are:但是,它可以格式化的语言(来自 VSCode 上的扩展页面)是:

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML

So I'm afraid no, this cannot be accomplished by Prettier as bash or shell are not on this list.所以恐怕不,这不能由 Prettier 完成,因为bashshell不在此列表中。

Prettier cannot format bash files. Prettier 无法格式化 bash 文件。 Instead you can try either shell-format or Bash Beautify extensions for VSCode to format your bash scripts.相反,您可以尝试使用shell 格式Bash 美化 VSCode扩展来格式化您的 bash 脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM