{ "scopeName": "source.shell", "name": "Shell Script", "fileTypes": [ "sh", "bash", "ksh", "zsh", "zsh-theme", "zshenv", "zlogin", "zlogout", "zprofile", "zshrc", "bashrc", "bash_aliases", "bash_profile", "bash_login", "profile", "bash_logout", ".textmate_init", "npmrc", "PKGBUILD", "install", "cygport", "bats", "ebuild" ], "firstLineMatch": "(?x)\n# Hashbang\n^\\#!.*(?:\\s|\\/)\n (?:bash|zsh|sh|tcsh|ksh|dash|ash|csh|rc)\n(?:$|\\s)\n|\n# Modeline\n(?i:\n # Emacs\n -\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)\n (?:shell-script|sh)\n (?=[\\s;]|(?]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s* set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=\n sh\n (?=\\s|:|$)\n)", "patterns": [ { "include": "#comment" }, { "include": "#pipeline" }, { "include": "#list" }, { "include": "#compound-command" }, { "include": "#loop" }, { "include": "#string" }, { "include": "#function-definition" }, { "include": "#variable" }, { "include": "#interpolation" }, { "include": "#heredoc" }, { "include": "#herestring" }, { "include": "#redirection" }, { "include": "#pathname" }, { "include": "#keyword" }, { "include": "#support" } ], "repository": { "case-clause": { "patterns": [ { "begin": "(?=\\S)", "end": ";;", "endCaptures": { "0": { "name": "punctuation.terminator.case-clause.shell" } }, "name": "meta.scope.case-clause.shell", "patterns": [ { "begin": "\\(|(?=\\S)", "beginCaptures": { "0": { "name": "punctuation.definition.case-pattern.shell" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.case-pattern.shell" } }, "name": "meta.scope.case-pattern.shell", "patterns": [ { "match": "\\|", "name": "punctuation.separator.pipe-sign.shell" }, { "include": "#string" }, { "include": "#variable" }, { "include": "#interpolation" }, { "include": "#pathname" } ] }, { "begin": "(?<=\\))", "end": "(?=;;)", "name": "meta.scope.case-clause-body.shell", "patterns": [ { "include": "$self" } ] } ] } ] }, "comment": { "begin": "(^\\s+)?(?<=^|\\W)(?|&&|\\|\\|", "name": "keyword.operator.logical.shell" }, { "match": "(?[>=]?|==|!=|^|\\|{1,2}|&{1,2}|\\?|\\:|,|=|[*/%+\\-&^|]=|<<=|>>=", "name": "keyword.operator.arithmetic.shell" }, { "match": "0[xX][0-9A-Fa-f]+", "name": "constant.numeric.hex.shell" }, { "match": "0\\d+", "name": "constant.numeric.octal.shell" }, { "match": "\\d{1,2}#[0-9a-zA-Z@_]+", "name": "constant.numeric.other.shell" }, { "match": "\\d+", "name": "constant.numeric.integer.shell" } ] }, "pathname": { "patterns": [ { "match": "(?<=\\s|:|=|^)~", "name": "keyword.operator.tilde.shell" }, { "match": "\\*|\\?", "name": "keyword.operator.glob.shell" }, { "begin": "([?*+@!])(\\()", "beginCaptures": { "1": { "name": "keyword.operator.extglob.shell" }, "2": { "name": "punctuation.definition.extglob.shell" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.extglob.shell" } }, "name": "meta.structure.extglob.shell", "patterns": [ { "include": "$self" } ] } ] }, "pipeline": { "patterns": [ { "match": "(?<=^|;|&|\\s)(time)(?=\\s|;|&|$)", "name": "keyword.other.shell" }, { "match": "[|!]", "name": "keyword.operator.pipe.shell" } ] }, "redirection": { "patterns": [ { "begin": "[><]\\(", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.interpolated.process-substitution.shell", "patterns": [ { "include": "$self" } ] }, { "match": "(?])(&>|\\d*>&\\d*|\\d*(>>|>|<)|\\d*<&|\\d*<>)(?![<>])", "name": "keyword.operator.redirect.shell" } ] }, "string": { "patterns": [ { "match": "\\\\.", "name": "constant.character.escape.shell" }, { "begin": "'", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "'", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.quoted.single.shell" }, { "begin": "\\$?\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "\"", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.quoted.double.shell", "patterns": [ { "match": "\\\\[\\$`\"\\\\\\n]", "name": "constant.character.escape.shell" }, { "include": "#variable" }, { "include": "#interpolation" } ] }, { "begin": "\\$'", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "'", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.quoted.single.dollar.shell", "patterns": [ { "match": "\\\\(a|b|e|f|n|r|t|v|\\\\|')", "name": "constant.character.escape.ansi-c.shell" }, { "match": "\\\\[0-9]{3}", "name": "constant.character.escape.octal.shell" }, { "match": "\\\\x[0-9a-fA-F]{2}", "name": "constant.character.escape.hex.shell" }, { "match": "\\\\c.", "name": "constant.character.escape.control-char.shell" } ] } ] }, "support": { "patterns": [ { "match": "(?<=^|;|&|\\s)(?::|\\.)(?=\\s|;|&|$)", "name": "support.function.builtin.shell" }, { "match": "(?<=^|;|&|\\s)(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)(?=\\s|;|&|$)", "name": "support.function.builtin.shell" } ] }, "variable": { "patterns": [ { "captures": { "1": { "name": "punctuation.definition.variable.shell" } }, "match": "(\\$)[a-zA-Z_][a-zA-Z0-9_]*", "name": "variable.other.normal.shell" }, { "captures": { "1": { "name": "punctuation.definition.variable.shell" } }, "match": "(\\$)[-*@#?$!0_]", "name": "variable.other.special.shell" }, { "captures": { "1": { "name": "punctuation.definition.variable.shell" } }, "match": "(\\$)[1-9]", "name": "variable.other.positional.shell" }, { "begin": "\\${", "beginCaptures": { "0": { "name": "punctuation.definition.variable.shell" } }, "end": "}", "endCaptures": { "0": { "name": "punctuation.definition.variable.shell" } }, "name": "variable.other.bracket.shell", "patterns": [ { "match": "!|:[-=?]?|\\*|@|#{1,2}|%{1,2}|/", "name": "keyword.operator.expansion.shell" }, { "captures": { "1": { "name": "punctuation.section.array.shell" }, "3": { "name": "punctuation.section.array.shell" } }, "match": "(\\[)([^\\]]+)(\\])" }, { "include": "#variable" }, { "include": "#string" } ] } ] } } }