Vscode-code-runner: Run files without extension (using code-runner.defaultLanguage)

Created on 14 Mar 2018  路  6Comments  路  Source: formulahendry/vscode-code-runner

I'd like to run files without extensions, typically bash scripts using your great code-runner extension

Currently it works if a script has the .sh extension, not without (which is more usual for scripts)

Is this possible to implement?

it could respect default language setting for those files

"code-runner.defaultLanguage": "shellscript",

running ./foo or bash foo or sh foo work in the terminal, before you ask (the file has the right permissions)

bug

Most helpful comment

Hi @caub , this issue has been fixed, please try the latest version.

All 6 comments

I think you could use code-runner.customCommand.

@formulahendry thanks, but I'd need a different shortcut to run it, not very practical

It's very common that bash/shell script are extension-less, so it would be great that it uses the defaultLanguage when there is no extension (that's the behavior with sublime-text). I cloned the repo, looked at the sources, but didn't find why it wasn't working. How can I load your extension locally instead of the marketplace one to test?

things I'd like to work on

  • add tests
  • run files with no extension using defaultLanguage mapping
  • try to read a possible hashbang in that case

Sorry, I am not very clear about you requirement. Could you please share more details? What's the current behavior? And what's your expected behavior?

To debug the extension, just clone the repo, run npm install, then press F5.

2018-03-19-131031_1354x1040_scrot

2018-03-19-131156_1354x1039_scrot

my code-runner settings:

    "code-runner.saveFileBeforeRun": true,
    // "code-runner.runInTerminal": true,
    "code-runner.clearPreviousOutput": true,
    "code-runner.defaultLanguage": "shellscript",
    "code-runner.enableAppInsights": false,
    "code-runner.showExecutionMessage": true,
    "code-runner.executorMap": {
        "sql": "psql -U postgres -f",
        "bash": "bash"
    },

I'd want to still be able to run the lol file, like I would run it if it were lol.sh or lol.bash

Oh! This is a bug of the extension.

Hi @caub , this issue has been fixed, please try the latest version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjaniec2013 picture mjaniec2013  路  5Comments

0x7FFFFFFFFFFFFFFF picture 0x7FFFFFFFFFFFFFFF  路  3Comments

seiferthan picture seiferthan  路  4Comments

N2ITN picture N2ITN  路  5Comments

sstorey-nephila picture sstorey-nephila  路  5Comments