Code Monkey home page Code Monkey logo

vs-shell-format's Introduction

Get it on the VS Code Marketplace!

supported file types or languages

language extension describe
shellscript .sh .bash shell script files
dockerfile Dockerfile docker files
ignore .gitignore .dockerignore ignore files
properties .properties java properties files
jvmoptions .vmoptions , jvm.options jvm options file
hosts /etc/hosts hosts file
bats .bats Bats test file

version downloads install ratings
Financial Contributors on Open Collective LICENSE LICENSE star forks

build release
CI RELEASE

Gitter chat


screenshot

usage

shift+option+f

shift+command+p then type Format Document

dependencies

custom configuration

  • shellformat.path the shfmt fullpath example [mac,linux]: /usr/local/bin/shfmt [windows]: C:\\bin\\shfmt.exe
  • shellformat.flag shfmt -h to see detailed usage.

Links

Enjoy shellscript!

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

vs-shell-format's People

Contributors

agross avatar clong-msec avatar dandavison avatar dependabot[bot] avatar edgardmessias avatar foxundermoon avatar greenraccoon23 avatar kunaltyagi avatar marzal avatar mcecode avatar mgor avatar monkeywithacupcake avatar ntwb avatar oliversalzburg avatar panissupraomnia avatar ralish avatar rasa avatar renovate-bot avatar renovate[bot] avatar rodrigobdz avatar saltchang avatar taebox avatar twz123 avatar xuehaipan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vs-shell-format's Issues

Install fails on Ubuntu 18.04

hbarta@baobabb:~$ mkdir -p /usr/local/bin
hbarta@baobabb:~$ curl -L 'https://github.com/mvdan/sh/releases/download/v2.6.2/shfmt_v2.6.2_linux_amd64' --output  /usr/local/bin/shfmt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   614    0   614    0     0   1149      0 --:--:-- --:--:-- --:--:--  1149
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0Warning: Failed to create the file /usr/local/bin/shfmt: Permission denied
  0 2826k    0 16360    0     0  12791      0  0:03:46  0:00:01  0:03:45 69617
curl: (23) Failed writing body (0 != 16360)
hbarta@baobabb:~$ chmod a+x /usr/local/bin/shfmt
chmod: cannot access '/usr/local/bin/shfmt': No such file or directory
hbarta@baobabb:~$ echo '**Enjoy shellscript!**'
**Enjoy shellscript!**
hbarta@baobabb:~$ echo 'fork or star  https://github.com/foxundermoon/vs-shell-format'
fork or star  https://github.com/foxundermoon/vs-shell-format
hbarta@baobabb:~$ 

/usr/local/bin is not writable by the user unless they are logged in as root. There are a couple possible fixes for this. One is to prefix the command with sudo (e.g. sudo mkdir -p /usr/local/bin) Which will prompt for the user's password (and will work if they are allowed to use the sudo command and it is installed.)
Another - and probably safer - alternative is to put the executable in ~/bin (expands to /home/<username>/bin) and is writable by the user without elevating privileges. If the directory exists, it will probably be in the $PATH. If not, it will be there on the next login. If your plugin provides the full path to shfmt, it should always work.

This is probably common to most, if not all, Linux variants.

"shellformat.flag" does not work at the project level in a multi-root workspace

In my project's folder, I have a .vscode/settings.json containing

{
    "shellformat.flag": "-sr",
    "editor.tabSize": 4,
    "editor.detectIndentation": true,
    "editor.renderWhitespace": "all",
    "editor.formatOnSave": true,
}

When I add my folder in a newly created workspace everything goes well. When I had more folders into the workspace, properties shellformat.* at the project level are not taken into account anymore.

I get a message saying

This setting cannot be applied in this workspace. It will be applied when you open the containing workspace folder directly.

No error message when using keyboard shortcut

Hello, thanks for this wonderful extension!

I am using VS Code Version 1.13.1 on Linux Fedora 25

When i use the format short-cut 'Shift+Ctrl I' if there are no errors it formats. If there are errors then nothing happens!

If I press F1 and select 'format shell with shfmt' then I see the error message appear that should also appear when I press the shortcut.

Thanks :)

Security: Don't install arbitrary binary on user system

image

An extension shouldn't download binaries from arbitrary sources:

https://github.com/mvdan/sh/releases/download/v2.6.4/shfmt_v2.6.4_windows_amd64.exe is arbitrary and out of the extension's control. This would be different if this extension is being published by @mdvan. Additionally, no one should trust extension didn't modify the URL to their own payload. [1] [2] [3]

Most systems run behind a package system (brew, chocolately, apt etc), which incorporate their own flows for getting packages to a system and safeguards (e.g. checksumming executable etc).

Instead, consider outputting instructions on how to safely source shfmt, for example:

shfmt doesn't appear to be available! We checked your $PATH, C:\bin, and C:\Windows\system32 and couldn't find shfmt.exe.

Based on detected OS (Windows), here are some options to make shfmt available:

Bug: Detecting existing shfmt

The logic to identify if shfmt is available on local machine/path is broken - it didn't detect the installed/available version of shfmt on the system.


I understand what this extension is trying to do (make it easy for this extension to work), but its breaking some cardinal security rules. Implementing some of the safety check (checksum executable) would not change this - extensions shouldn't source arbitrary binaries.

Too much output regarding Download Progress

Literally a copy-paste of the console output:

downloaded:[0.50%]
downloaded:[0.52%]
downloaded:[1.02%]
downloaded:[1.05%]
downloaded:[1.55%]
downloaded:[1.58%]
downloaded:[2.08%]
downloaded:[2.12%]
downloaded:[2.62%]
downloaded:[2.65%]
downloaded:[3.15%]
downloaded:[3.18%]
downloaded:[3.68%]
downloaded:[3.71%]
downloaded:[4.21%]
downloaded:[4.25%]
downloaded:[4.75%]
downloaded:[4.78%]
downloaded:[5.28%]
downloaded:[5.31%]
downloaded:[5.81%]
downloaded:[5.84%]
downloaded:[6.35%]
downloaded:[6.38%]
downloaded:[6.88%]
downloaded:[6.91%]
downloaded:[7.41%]
downloaded:[7.44%]
downloaded:[7.94%]
downloaded:[7.98%]
downloaded:[8.48%]
downloaded:[8.51%]
downloaded:[9.01%]
downloaded:[9.04%]
downloaded:[9.54%]
downloaded:[9.57%]
downloaded:[10.07%]
downloaded:[10.11%]
downloaded:[10.61%]
downloaded:[10.64%]
downloaded:[11.14%]
downloaded:[11.17%]
downloaded:[11.67%]
downloaded:[11.70%]
downloaded:[12.20%]
downloaded:[12.24%]
downloaded:[12.74%]
downloaded:[12.77%]
downloaded:[13.27%]
downloaded:[13.30%]
downloaded:[13.80%]
downloaded:[13.83%]
downloaded:[14.33%]
downloaded:[14.37%]
downloaded:[14.87%]
downloaded:[14.90%]
downloaded:[15.40%]
downloaded:[15.43%]
downloaded:[15.93%]
downloaded:[15.96%]
downloaded:[16.47%]
downloaded:[16.50%]
downloaded:[17.00%]
downloaded:[17.03%]
downloaded:[17.53%]
downloaded:[17.56%]
downloaded:[18.06%]
downloaded:[18.10%]
downloaded:[18.60%]
downloaded:[18.63%]
downloaded:[19.13%]
downloaded:[19.16%]
downloaded:[19.66%]
downloaded:[19.69%]
downloaded:[20.19%]
downloaded:[20.23%]
downloaded:[20.73%]
downloaded:[20.76%]
downloaded:[21.26%]
downloaded:[21.29%]
downloaded:[21.79%]
downloaded:[21.82%]
downloaded:[22.32%]
downloaded:[22.36%]
downloaded:[22.86%]
downloaded:[22.89%]
downloaded:[23.39%]
downloaded:[23.42%]
downloaded:[23.92%]
downloaded:[23.95%]
downloaded:[24.45%]
downloaded:[24.49%]
downloaded:[24.99%]
downloaded:[25.02%]
downloaded:[25.52%]
downloaded:[25.55%]
downloaded:[26.05%]
downloaded:[26.08%]
downloaded:[26.59%]
downloaded:[26.62%]
downloaded:[27.12%]
downloaded:[27.15%]
downloaded:[27.65%]
downloaded:[27.68%]
downloaded:[28.18%]
downloaded:[28.22%]
downloaded:[28.72%]
downloaded:[28.75%]
downloaded:[29.25%]
downloaded:[29.28%]
downloaded:[29.78%]
downloaded:[29.81%]
downloaded:[30.31%]
downloaded:[30.35%]
downloaded:[30.85%]
downloaded:[30.88%]
downloaded:[31.38%]
downloaded:[31.41%]
downloaded:[31.91%]
downloaded:[31.94%]
downloaded:[32.44%]
downloaded:[32.48%]
downloaded:[32.98%]
downloaded:[33.01%]
downloaded:[33.51%]
downloaded:[33.54%]
downloaded:[34.04%]
downloaded:[34.07%]
downloaded:[34.57%]
downloaded:[34.61%]
downloaded:[35.11%]
downloaded:[35.14%]
downloaded:[35.64%]
downloaded:[35.67%]
downloaded:[36.17%]
downloaded:[36.20%]
downloaded:[36.71%]
downloaded:[36.74%]
downloaded:[37.24%]
downloaded:[37.27%]
downloaded:[37.77%]
downloaded:[37.80%]
downloaded:[38.30%]
downloaded:[38.34%]
downloaded:[38.84%]
downloaded:[38.87%]
downloaded:[39.37%]
downloaded:[39.40%]
downloaded:[39.90%]
downloaded:[39.93%]
downloaded:[40.43%]
downloaded:[40.47%]
downloaded:[40.97%]
downloaded:[41.00%]
downloaded:[41.50%]
downloaded:[41.53%]
downloaded:[42.03%]
downloaded:[42.06%]
downloaded:[42.56%]
downloaded:[42.60%]
downloaded:[43.10%]
downloaded:[43.13%]
downloaded:[43.63%]
downloaded:[43.66%]
downloaded:[44.16%]
downloaded:[44.19%]
downloaded:[44.69%]
downloaded:[44.73%]
downloaded:[45.23%]
downloaded:[45.26%]
downloaded:[45.76%]
downloaded:[45.79%]
downloaded:[46.29%]
downloaded:[46.32%]
downloaded:[46.83%]
downloaded:[46.86%]
downloaded:[47.36%]
downloaded:[47.39%]
downloaded:[47.89%]
downloaded:[47.92%]
downloaded:[48.42%]
downloaded:[48.46%]
downloaded:[48.96%]
downloaded:[48.99%]
downloaded:[49.49%]
downloaded:[49.52%]
downloaded:[50.02%]
downloaded:[50.05%]
downloaded:[50.55%]
downloaded:[50.59%]
downloaded:[51.09%]
downloaded:[51.12%]
downloaded:[51.62%]
downloaded:[51.65%]
downloaded:[52.15%]
downloaded:[52.18%]
downloaded:[52.68%]
downloaded:[52.72%]
downloaded:[53.22%]
downloaded:[53.25%]
downloaded:[53.75%]
downloaded:[53.78%]
downloaded:[54.28%]
downloaded:[54.31%]
downloaded:[54.81%]
downloaded:[54.85%]
downloaded:[55.35%]
downloaded:[55.38%]
downloaded:[55.88%]
downloaded:[55.91%]
downloaded:[56.41%]
downloaded:[56.44%]
downloaded:[56.95%]
downloaded:[56.98%]
downloaded:[57.48%]
downloaded:[57.51%]
downloaded:[58.01%]
downloaded:[58.04%]
downloaded:[58.54%]
downloaded:[58.58%]
downloaded:[59.08%]
downloaded:[59.11%]
downloaded:[59.61%]
downloaded:[59.64%]
downloaded:[60.14%]
downloaded:[60.17%]
downloaded:[60.67%]
downloaded:[60.71%]
downloaded:[61.21%]
downloaded:[61.24%]
downloaded:[61.74%]
downloaded:[61.77%]
downloaded:[62.27%]
downloaded:[62.30%]
downloaded:[62.80%]
downloaded:[62.84%]
downloaded:[63.34%]
downloaded:[63.37%]
downloaded:[63.87%]
downloaded:[63.90%]
downloaded:[64.40%]
downloaded:[64.43%]
downloaded:[64.93%]
downloaded:[64.97%]
downloaded:[65.47%]
downloaded:[65.50%]
downloaded:[66.00%]
downloaded:[66.03%]
downloaded:[66.53%]
downloaded:[66.56%]
downloaded:[67.07%]
downloaded:[67.10%]
downloaded:[67.60%]
downloaded:[67.63%]
downloaded:[68.13%]
downloaded:[68.16%]
downloaded:[68.66%]
downloaded:[68.70%]
downloaded:[69.20%]
downloaded:[69.23%]
downloaded:[69.73%]
downloaded:[69.76%]
downloaded:[70.26%]
downloaded:[70.29%]
downloaded:[70.79%]
downloaded:[70.83%]
downloaded:[71.33%]
downloaded:[71.36%]
downloaded:[71.86%]
downloaded:[71.89%]
downloaded:[72.39%]
downloaded:[72.42%]
downloaded:[72.92%]
downloaded:[72.96%]
downloaded:[73.46%]
downloaded:[73.49%]
downloaded:[73.99%]
downloaded:[74.02%]
downloaded:[74.52%]
downloaded:[74.55%]
downloaded:[75.05%]
downloaded:[75.09%]
downloaded:[75.59%]
downloaded:[75.62%]
downloaded:[76.12%]
downloaded:[76.15%]
downloaded:[76.65%]
downloaded:[76.68%]
downloaded:[77.19%]
downloaded:[77.22%]
downloaded:[77.72%]
downloaded:[77.75%]
downloaded:[78.25%]
downloaded:[78.28%]
downloaded:[78.78%]
downloaded:[78.82%]
downloaded:[79.32%]
downloaded:[79.35%]
downloaded:[79.85%]
downloaded:[79.88%]
downloaded:[80.38%]
downloaded:[80.41%]
downloaded:[80.91%]
downloaded:[80.95%]
downloaded:[81.45%]
downloaded:[81.48%]
downloaded:[81.98%]
downloaded:[82.01%]
downloaded:[82.51%]
downloaded:[82.54%]
downloaded:[83.04%]
downloaded:[83.08%]
downloaded:[83.58%]
downloaded:[83.61%]
downloaded:[84.11%]
downloaded:[84.14%]
downloaded:[84.64%]
downloaded:[84.67%]
downloaded:[85.17%]
downloaded:[85.21%]
downloaded:[85.71%]
downloaded:[85.74%]
downloaded:[86.24%]
downloaded:[86.27%]
downloaded:[86.77%]
downloaded:[86.80%]
downloaded:[87.31%]
downloaded:[87.34%]
downloaded:[87.84%]
downloaded:[87.87%]
downloaded:[88.37%]
downloaded:[88.40%]
downloaded:[88.90%]
downloaded:[88.93%]
downloaded:[89.44%]
downloaded:[89.47%]
downloaded:[89.97%]
downloaded:[90.00%]
downloaded:[90.50%]
downloaded:[90.53%]
downloaded:[91.03%]
downloaded:[91.07%]
downloaded:[91.57%]
downloaded:[91.60%]
downloaded:[92.10%]
downloaded:[92.13%]
downloaded:[92.63%]
downloaded:[92.66%]
downloaded:[93.16%]
downloaded:[93.20%]
downloaded:[93.70%]
downloaded:[93.73%]
downloaded:[94.23%]
downloaded:[94.26%]
downloaded:[94.76%]
downloaded:[94.79%]
downloaded:[95.29%]
downloaded:[95.33%]
downloaded:[95.83%]
downloaded:[95.86%]
downloaded:[96.36%]
downloaded:[96.39%]
downloaded:[96.89%]
downloaded:[96.92%]
downloaded:[97.43%]
downloaded:[97.46%]
downloaded:[97.96%]
downloaded:[97.99%]
downloaded:[98.49%]
downloaded:[98.52%]
downloaded:[99.02%]
downloaded:[99.05%]
downloaded:[99.56%]
downloaded:[99.59%]
downloaded:[100.00%]

This happens so fast, it's impossible to control/see what's happening and why. Can the output be throttled such that it's once per second or per 1% download whichever is more? If I read the code correctly, currently, the output is per chunk which doesn't make sense from ux pov.

Even using dots per percent and a detailed print every 5% would be more than informative enough.

Example (one dot per chunk which is not bringing the count to multiples of 5)

downloaded: [0.50%].................
downloaded: [5.28%]
and so on

brew install shfmt failed with Xcode 10.1

brew install shfmt

Error: Your Xcode (1) is too outdated.
Please update to Xcode 9.0 (or delete it).
Xcode can be updated from
  https://developer.apple.com/download/more/

Error: Your Command Line Tools are too outdated.
Update them from Software Update in the App Store.

but my Xcode version is 10.1

xcodebuild -version

Xcode 10.1

.env files formatted

Hi - great product.

This works fine when I am using .sh files but it's also formatting my .env files - which is causing my vars to be broken as its splitting strings etc...

Issues about formatting the shell scripts with "="

In script,the comparison between string and string.it will be like if [ $1 = "String" ].But use the plugin to format,this will change to if [ $1="String" ],this behaviour will change the result of this expression.

Trojan?

Just got this alert from Windows Defender...

image

Please advise ...

Thanks

Format Dockerfiles in terminal

Is there a version of the Dockerfile formatter that this extension uses that we could call from the shell for usage on CI?

No formatter for 'shellscript'-files installed.

I have installed the shfmt binary release file in usr/local/bin/shfmt
I have also installed it using go get -u github.com/mvdan/sh/cmd/shfmt in $HOME/go/bin/shfmt
I tried set shellformat.path to both paths, but neither worked.

System: Ubuntu 16.04
Go version: 1.9.2
shfmt version: 2.2.0

Formmater replace `` into $()

I want to assign the dns result to dns_server by networksetup -getdnsservers Wi-Fi in the shellscript, but after I format it, the formatter replace `` into $(), show as below:

before format:

dns_server=`networksetup -getdnsservers Wi-Fi`

after format:

dns_server=$(networksetup -getdnsservers Wi-Fi)

formatting problem with SQLPLUS

Please take a look at the formatting of code below:

RETVAL='sqlplus -S ${V_ETL_TECH_LOGIN} <<EOF
${SQL_COMMAND}
EOF'

#lines below are green as if they were a part of text above
ERROR_CODE=$?

Lines below are no longer properly formatted (colored).

The good example of what I mean is to take a look at the Sublime Text editor code.
Well, to be honest, recently I realized that even in Sublime Text this example is wrongly formatted. It colorize commands like "if" but forget about variables.
From free editors I use now the best formatting is offered by Notepad++. Please take a look for examples there.

Strange file permissions for binary file.

Hi there,

I just noticed this, because my backup tool complained that it wasn't allowed to copy shfmt_v2.6.4_linux_amd64. I'm wondering what's with the strange permission of that file?

$ ls -la ~/.vscode-oss/extensions/foxundermoon.shell-format-6.1.1/bin | grep shfmt

drwxr-xr-x 2 peter peter    4096 Aug 16 13:01 .
drwxr-xr-x 4 peter peter    4096 Aug 16 13:01 ..
--wxrw--wt 1 peter peter 3005216 Aug 16 13:01 shfmt_v2.6.4_linux_amd64

Use Format Document command

screenshot
Would it be possible for this extension to just use the Format Document command? I have a few other formatters for various other languages and they all use Format Document rather than having a separate command.

Formatting attempted with VALA files

Hi there, I have shfmt setup in Vscode to format on save. For some reason, the extension is trying to process a Vala file I am working on. Is there a way to disable for a certain file type?

cant install shfmt

I receive the notification to install shfm using the command go get -u github.com/mvdan/sh/cmd/shfmt.
But it doesn't work. I receive the following output.

$ go get -u github.com/mvdan/sh/cmd/shfmt
# github.com/mvdan/sh/cmd/shfmt
/opt/go/src/github.com/mvdan/sh/cmd/shfmt/main.go:156: undefined: io.SeekStart

piped commands are not formatted

Hi,

If I write for example:

days=$(echo $1 | perl -ne '/(\d*) day/ && print"$1"')

then the perl -ne is not formatted as expected

Is it possible to make = same class as if, then etc?

how does the recognition of applications work?

Support variables in the path

Using variables in the path causes an invalid error:

"shellformat.path": "${HOME}/go/bin/shfmt"

or ${env:HOME}

Error:

the config shellformat.path file not exists please fix it

However apart from the error, the extension works fine.

[shellformat.path] not configured

Hi, I'm trying out your Visual Studio Code Extension, but I can't get it to run. I guess I must be stupid.
I'm on Windows 10 1803 x64. Visual Studio Code:

Version: 1.29.1 (user setup)
Commit: bc24f98b5f70467bc689abf41cc5550ca637088e
Datum: 2018-11-15T19:13:36.375Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architektur: x64

I've downloaded "https://github.com/mvdan/sh/releases/download/v2.6.2/shfmt_v2.6.2_windows_amd64.exe" and placed it in a folder.
I then added the path to my custom user settings:
grafik
But regardless what path I enter, I get the error message: [shellformat.path] not configured
Things I tried:

"C:\#Apps\shfmt_v2.6.2_windows_amd64.exe"
"C:\\#Apps\\shfmt_v2.6.2_windows_amd64.exe"
"C:/#Apps/shfmt_v2.6.2_windows_amd64.exe"
"C:\shfmt_v2.6.2_windows_amd64.exe"
"C:\\shfmt_v2.6.2_windows_amd64.exe"
"C:/shfmt_v2.6.2_windows_amd64.exe"
"C:\shfmt.exe"
"C:\\shfmt.exe"
"C:/shfmt.exe"

I've no idea what basic thing I'm doing wrong. Can you help me please?

Formatting breaks dockerfiles

Remove trailing slashes, causing RUN command to fail.

Before format:

FROM alpine:3.9
RUN apk add --no-cache \
    bash \
    python \
    py-pip \
  && pip install awscli --upgrade \
  && apk del py-pip
CMD ["/bin/bash"]

After format:

FROM alpine:3.9
RUN apk add --no-cache \
    bash \
    python \
    py-pip &&
pip install awscli --upgrade &&
apk del py-pip
CMD ["/bin/bash"]

Add a License

Please add a license so that the terms of use for this open source software are clear!

Disable NewLine at EOF

Is there a flag to disable newline at EOF for bash scripts for shell-format.
When I disable the extension, the newline is not added.

Running format breaks Dockerfiles

When running format on Dockerfiles it removes all of the \ and line endings. This causes RUN commands in docker build to not work.

Runnning shell-format 4.0.4 and shfmt 2.6.3

Selection Formatter For Shell Files

I just installed vs-shell-format in order to have a shellscript formatter available to my VSCode workspace. It looks like document formatting works fine (ie, ALT-SHIFT-F to format the entire document), but selection formatting is not (ie, CMD-K CMD-F on highlighted text). It would be ideal if this extension supported both document formatting and selection formatting. I'm not sure if this is a feature request (has not yet been implemented in this extension) or a bug report (ie, it should work but it is not).

My workspace info:

  • MacOS 10.14.3
  • VSCode 1.31.1
  • vs-shell-format 4.0.4

Thank you!

Option -i seems not working anymore in VSCode V1.31.1

Hello,
In VSCode I cannot set the increment anymore (my shfmt version is 2.5.1)
Whatever the -i number I used I have 5 whitespace in my script.
Please note

  • In VSCode, all others options are working well (I tested -p, -ci, -h, -w ...)
  • In VSCode "terminal windows" -i option is working well

I really think it is not linked to shfmt himself but it's integration in VSCode.
Perhaps something is running at 'Format document' after shfmt which change the indent to '5'

But I have no idea of how I can debug this.

Note than before this was integrated to the 'system' Format Document, I had no problem ... I am so sad ...

In order to help you, is there a way to debug this?

Thanks in advance for your help, regards,
Pierre

The code
#!/bin/sh
if [ "${a}" = "a" ]; then
echo "toto"
echo "toto" > tata
fi
the options:
"shellformat.flag": "-i 0 -p -ci -sr -kp",
"shellformat.path": "E:\programfiles\shfmt\shfmt.exe",
"shellformat.showError": true,

multiple runs cause extra newlines

for example: you have script:
[ ... ] \
&& {...;}

after first run with -bn you'll get
[ ... ] \
\
&& {...;}

after second:
[ ... ] \
\
\
&& {...;}

and so on...

is only formatting *.sh file?

I use those setting:

  "shellformat.flag": "-i 2 -sr -bn",
  "shellformat.runOnSave": true,

Sometimes, when I save REAME.md, it will do format and repace ` with $() .

Editorconfig is being ignored

Hi, thanks for the extension!

shfmt supports using a .editorconfig to define settings. I have the following a the root of the project:

[*]
indent_style = space
indent_size = 4
binary_next_line = true
switch_case_indent = true

This works as expected using shfmt from the terminal, however using this extension those settings are ignored. Just wondering if this is expected?

Update VS code and shell-format don't work anymore

Hello, sorry I am a newly in Linux (and in english) and I have perhaps make a mistake.
I have updated VS code and it works fine.

I have kept shell-format extension (same place, same options) I have no notification nor errors nor problem in the VS logs.

But I cannot find shell-format command in F1, it does not appears. In terminal I wrote "shfmt -version" and it answer V2.5.0.

Please what can i do to retreive my command?

Thanks a lot,
Pierre

problems to run the shell format ext

Hi
I install the shell-format 0.1.3 in the vscode but it don´t run.
I try to run in the console with format shell with shfmt option but the code in bash and ksh shell is the same and not formated.
My version of the softwares:

C:\Users\claud\t>ver

Microsoft Windows [versão 10.0.14393]

C:\Users\claud\t>go version
go version go1.8 windows/amd64

C:\Users\claud\t>shfmt -version
v1.2.0

Cannot read property 'substring' of undefined

Running the formatter in vscode throws

Cannot read property 'substring' of undefined

However, after running shfmt -w myscript.sh once from the command line manually, it worked fine.

Please clarify what the donations are for

The README mentions many donation methods, saying that they will make shell-format better. Please clarify that these donations won't reach shfmt, as I didn't even know anyone was receiving donations for software sitting on top of mine.

To clarify, I don't mind if you do take donations. But please make it clear that the donations may make the plugin better, but not the actual shell formatting software that it depends on.

shfmt always check fail

vscode logs : (vscode version :1.30.2)

"shellformat.path": "/usr/local/bin/shfmt"   find config shellformat path ,but the file cannot execute or not exists, so will auto download shfmt
shfmt hasn't downloaded yet!TypeError: Cannot read property 'stat' of undefined
Shfmt will be downloaded automatically!
download url: https://github.com/mvdan/sh/releases/download/v2.6.4/shfmt_v2.6.4_darwin_amd64
download to: /usr/local/bin/shfmt
If the download fails, you can manually download it to the dest directory.
Or download to another directory, and then set the "shellformat.path" as the path
download shfmt page: https://github.com/mvdan/sh/releases
You can't use this plugin until the download is successful.
download failed: Error: EACCES: permission denied, open '/usr/local/bin/shfmt'

file shfmt

ls -l /usr/local/bin/shfmt
lrwxr-xr-x  1 liuchuanfeng  admin  39 10 30 16:09 /usr/local/bin/shfmt -> /usr/local/Cellar/shfmt/2.6.4/bin/shfmt

shfmt version

 /usr/local/bin/shfmt --version
v2.6.4

actually ,it's ok to use it format shell file;but always ouput fail and try download ;pls help it

Cursor focus is stolen by update

When the extension automatically updates shellfmt, focus is stolen by the Output window which shows up to report download process. I experienced this while writing a Rust file, and every time it reported the download progress percentage, my cursor was moved back to the output window, so I was forced to wait until the download finished.

Repeatedly running shell commands in my VS Code Terminal is very annoying

  1. What is the purpose of this extension frequently opening the VS Code terminal to run shell commands? (It has happened a few times already today, once when I opened VS Code and later apparently randomly.)

a. Why must you run the command?
b. Why so often?
c. Why in the VS Code Terminal?

  1. Is there some other way to achieve any legitimate purposes that does not create such a negative user experience?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.