{ "scopeName": "source.shell", "name": "Shell Script", "fileTypes": [ "sh", "bash", "ksh", "zsh", "zsh-theme", "zshenv", "zlogin", "zlogout", "zprofile", "zshrc", "bashrc", "bash_profile", "bash_login", "profile", "bash_logout", ".textmate_init", "npmrc", "PKGBUILD", "install", "cygport", "bats", "ebuild" ], "firstLineMatch": "^#!.*\\b(bash|zsh|sh|tcsh|ksh|dash|ash|csh|rc)|(?i:^\\s*#\\s*-\\*-[^*]*mode:\\s*shell-script[^*]*-\\*-)", "patterns": [ { "include": "#comment" }, { "include": "#pipeline" }, { "include": "#list" }, { "include": "#compound-command" }, { "include": "#loop" }, { "include": "#function-definition" }, { "include": "#string" }, { "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))", "captures": { "0": { "name": "punctuation.definition.case-pattern.shell" } }, "end": "\\)", "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+)?(?|&&|\\|\\|", "name": "keyword.operator.logical.shell" }, { "match": "(?[>=]?|==|!=|^|\\|{1,2}|&{1,2}|\\?|\\:|,|=|[*/%+\\-&^|]=|<<=|>>=", "name": "keyword.operator.arithmetic.shell" }, { "match": "0[xX]\\h+", "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": { "1": { "name": "punctuation.definition.extglob.shell" } }, "name": "meta.structure.extglob.shell", "patterns": [ { "include": "$self" } ] } ] }, "pipeline": { "patterns": [ { "match": "\\b(time)\\b", "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" } ] }, { "comment": "valid: &>word >&word >word [n]>&[n] [n]word [n]>>word [n]<&word (last one is duplicate)", "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": "(?