--- 
name: Shell Script (Bash)
fileTypes: 
- sh
- ss
- bashrc
- bash_profile
- bash_login
- profile
- bash_logout
firstLineMatch: ^#!.*(bash|zsh|sh|tcsh)
scopeName: source.shell
repository: 
  interpolation: 
    patterns: 
    - name: string.interpolated.backtick.shell
      endCaptures: 
        "0": 
          name: punctuation.definition.string.end.shell
      begin: "`"
      beginCaptures: 
        "0": 
          name: punctuation.definition.string.begin.shell
      end: "`"
      patterns: 
      - name: constant.character.escape.shell
        match: \\[`\\$]
    - name: string.interpolated.dollar.shell
      endCaptures: 
        "0": 
          name: punctuation.definition.string.end.shell
      begin: \$\(
      beginCaptures: 
        "0": 
          name: punctuation.definition.string.begin.shell
      end: \)
      patterns: 
      - include: $self
  variable: 
    patterns: 
    - name: variable.other.special.shell
      captures: 
        "1": 
          name: punctuation.definition.variable.shell
      match: (\$)[-*@#?$!0_]
    - name: variable.other.positional.shell
      captures: 
        "1": 
          name: punctuation.definition.variable.shell
      match: (\$)[1-9]
    - name: variable.other.normal.shell
      captures: 
        "1": 
          name: punctuation.definition.variable.shell
      match: (\$)[a-zA-Z_][a-zA-Z0-9_]*
    - name: variable.other.bracket.shell
      captures: 
        "0": 
          name: punctuation.definition.variable.shell
      begin: \$\{
      end: \}
uuid: DDEEA3ED-6B1C-11D9-8B10-000D93589AF6
foldingStartMarker: \{
patterns: 
- name: support.function.shell
  match: \b(time)\b
- name: keyword.operator.list.shell
  match: ;|&&|&|\|\|
- name: keyword.operator.pipe.shell
  match: "[|!]"
- name: meta.scope.logical-expression.shell
  captures: 
    "1": 
      name: punctuation.definition.logical-expression.shell
  begin: (\[{2})
  end: (\]{2})
  patterns: 
  - name: keyword.operator.logical.shell
    match: ==|!=|&&|!|\|\|
    comment: do we want a special rule for ( expr )?
  - include: $self
- name: meta.scope.expression.shell
  captures: 
    "1": 
      name: punctuation.definition.expression.shell
  begin: (\({2})
  end: (\){2})
  patterns: 
  - include: $self
- name: meta.scope.subshell.shell
  captures: 
    "1": 
      name: punctuation.definition.subshell.shell
  begin: (\()
  end: (\))
  patterns: 
  - include: $self
- name: meta.scope.group.shell
  captures: 
    "1": 
      name: punctuation.definition.group.shell
  begin: (?<=\s|^)(\{)(?=\s|$)
  end: (?<=^|;)\s*(\})
  patterns: 
  - include: $self
- name: constant.character.escape.shell
  match: \\.
- name: string.quoted.single.shell
  endCaptures: 
    "0": 
      name: punctuation.definition.string.end.shell
  begin: "'"
  beginCaptures: 
    "0": 
      name: punctuation.definition.string.begin.shell
  end: "'"
- name: string.quoted.double.shell
  endCaptures: 
    "0": 
      name: punctuation.definition.string.end.shell
  begin: \$?"
  beginCaptures: 
    "0": 
      name: punctuation.definition.string.begin.shell
  end: "\""
  patterns: 
  - name: constant.character.escape.shell
    match: \\[\$`"\\\n]
  - include: "#variable"
  - include: "#interpolation"
- name: string.quoted.single.dollar.shell
  endCaptures: 
    "0": 
      name: punctuation.definition.string.end.shell
  begin: \$'
  beginCaptures: 
    "0": 
      name: punctuation.definition.string.begin.shell
  end: "'"
  patterns: 
  - name: constant.character.escape.ansi-c.shell
    match: \\(a|b|e|f|n|r|t|v|\\|')
  - name: constant.character.escape.octal.shell
    match: \\[0-9]{3}
  - name: constant.character.escape.hex.shell
    match: \\x[0-9a-fA-F]{2}
  - name: constant.character.escape.control-char.shell
    match: \\c.
- name: keyword.operator.tilde.shell
  match: (?<=\s|:|=|^)~
- include: "#variable"
- include: "#interpolation"
- name: string.other.math.shell
  endCaptures: 
    "0": 
      name: punctuation.definition.string.end.shell
  begin: \$\({2}
  beginCaptures: 
    "0": 
      name: punctuation.definition.string.begin.shell
  end: \){2}
- name: string.interpolated.process-substitution.shell
  endCaptures: 
    "0": 
      name: punctuation.definition.string.end.shell
  begin: "[><]\\("
  beginCaptures: 
    "0": 
      name: punctuation.definition.string.begin.shell
  end: \)
- name: string.unquoted.heredoc.no-indent.ruby.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)-("|'|)(RUBY)\2
  contentName: source.ruby.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^\t*(RUBY)$
  patterns: 
  - include: source.ruby
- name: string.unquoted.heredoc.ruby.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)("|'|)(RUBY)\2
  contentName: source.ruby.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^(RUBY)$
  patterns: 
  - include: source.ruby
- name: string.unquoted.heredoc.no-indent.applescript.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)-("|'|)(APPLESCRIPT)\2
  contentName: source.applescript.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^\t*(APPLESCRIPT)$
  patterns: 
  - include: source.applescript
- name: string.unquoted.heredoc.applescript.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)("|'|)(APPLESCRIPT)\2
  contentName: source.applescript.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^(APPLESCRIPT)$
  patterns: 
  - include: source.applescript
- name: string.unquoted.heredoc.no-indent.html.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)-("|'|)(HTML)\2
  contentName: text.html.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^\t*(HTML)$
  patterns: 
  - include: text.html.basic
- name: string.unquoted.heredoc.html.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)("|'|)(HTML)\2
  contentName: text.html.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^(HTML)$
  patterns: 
  - include: text.html.basic
- name: string.unquoted.heredoc.no-indent.markdown.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)-("|'|)(MARKDOWN)\2
  contentName: text.html.markdown.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^\t*(MARKDOWN)$
  patterns: 
  - include: text.html.markdown
- name: string.unquoted.heredoc.markdown.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)("|'|)(MARKDOWN)\2
  contentName: text.html.markdown.embedded.shell
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^(MARKDOWN)$
  patterns: 
  - include: text.html.markdown
- name: string.unquoted.heredoc.no-indent.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)-("|'|)\\?(\w+)\2
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^\t*(\3)$
- name: string.unquoted.heredoc.shell
  endCaptures: 
    "1": 
      name: keyword.control.heredoc-token.shell
  captures: 
    "0": 
      name: punctuation.definition.string.shell
  begin: (<<)("|'|)\\?(\w+)\2
  beginCaptures: 
    "1": 
      name: keyword.operator.heredoc.shell
    "3": 
      name: keyword.control.heredoc-token.shell
  end: ^(\3)$
- name: meta.herestring.shell
  captures: 
    "1": 
      name: keyword.operator.herestring.shell
    "2": 
      name: string.quoted.single.herestring.shell
    "3": 
      name: punctuation.definition.string.begin.shell
    "4": 
      name: punctuation.definition.string.end.shell
  match: (<<<)((')[^']*('))
- name: meta.herestring.shell
  captures: 
    "6": 
      name: punctuation.definition.string.end.shell
    "1": 
      name: keyword.operator.herestring.shell
    "2": 
      name: string.quoted.double.herestring.shell
    "3": 
      name: punctuation.definition.string.begin.shell
  match: (<<<)((")(\\("|\\)|[^"])*("))
- name: meta.herestring.shell
  captures: 
    "1": 
      name: keyword.operator.herestring.shell
    "2": 
      name: string.unquoted.herestring.shell
  match: (<<<)(([^\s\\]|\\.)+)
- name: keyword.operator.redirect.shell
  match: "&>|\\d*>&\\d*|\\d*(>>|>|<)|\\d*<&|\\d*<>"
  comment: "valid: &>word >&word >word [n]>&[n] [n]<word [n]>word [n]>>word [n]<&word (last one is duplicate)"
- name: comment.line.number-sign.shell
  captures: 
    "1": 
      name: punctuation.definition.comment.shell
  match: (?<!\$)(#)(?!\{).*$\n?
- name: meta.function.shell
  captures: 
    "1": 
      name: entity.name.function.shell
    "2": 
      name: punctuation.definition.arguments.shell
  match: \b([^ \t\n]*)\s*(\(\))
- name: keyword.control.shell
  match: \b(?:if|then|else|elif|fi|for|in|do|done|select|case|continue|esac|while|until)\b
- name: storage.modifier.shell
  match: \b(?:export)\b
foldingStopMarker: \}
keyEquivalent: ^~S
