%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: Shell Script (Bash) file_extensions: - sh - bash - zsh - .bash_aliases - .bash_functions - .bash_login - .bash_logout - .bash_profile - .bash_variables - .bashrc - .profile - .textmate_init first_line_match: '^#!.*\b(bash|zsh|sh|tcsh)|^#\s*-\*-[^*]*mode:\s*shell-script[^*]*-\*-' scope: source.shell contexts: main: - 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 comment: - match: '(?|&&|\|\|' comment: do we want a special rule for ( expr )? scope: keyword.operator.logical.shell - match: '(?[>=]?|==|!=|^|\|{1,2}|&{1,2}|\?|\:|,|=|[*/%+\-&^|]=|<<=|>>=' scope: keyword.operator.arithmetic.shell - match: '0[xX]\h+' scope: constant.numeric.hex.shell - match: '0\d+' scope: constant.numeric.octal.shell - match: '\d{1,2}#[0-9a-zA-Z@_]+' scope: constant.numeric.other.shell - match: \d+ scope: constant.numeric.integer.shell pathname: - match: '(?<=[a-zA-Z0-9_])=(?=\s*$|[^\s])' scope: keyword.operator.assign.shell - match: (?<=\s|:|=|^)~ scope: keyword.operator.tilde.shell - match: \*|\? scope: keyword.operator.glob.shell - match: '([?*+@!])(\()' captures: 1: keyword.operator.extglob.shell 2: punctuation.definition.extglob.shell push: - meta_scope: meta.structure.extglob.shell - match: (\)) captures: 1: punctuation.definition.extglob.shell pop: true - include: main pipeline: - match: '\b(clang\+\+|g\+\+)' scope: keyword.other.shell - match: '\b(7za|alias|apropos|apt-get|aptitude|ar|aspell|autoconf|awk|base64|basename|bash|bc|bg|bind|brew|builtin|bzip2|cal|cat|cc|cd|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clang|clear|cmake|cmp|comm|command|cp|cron|crontab|crontab|csh|lua|csplit|cut|date|dc|dd|ddrescue|declare|depmod|df|diff3?|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|thtool|eval|exec|exit|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|function|fuser|gawk|gcc|getopts|git|grep|groupadd|groupdel|groupmd|groups|gzip|hash|head|help|hg|history|hostname|iconv|id|ifconfig|ifdown|ifup|import|insmod|install|jar|java|jobs|join|kill|killall|kmod|less|let|link|llvm|ln|local|locate|logname|loout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsod|lsof|mail|make|man|md5sum|mkdir|mkfifo|mkisofs|mknod|mmv|modinfo|modprobe|more|most|mount|mtools|mtr|mutt|mv|mysql|netstat|nice|nl|nohup|notify-se|nslookup|nstat|op|open|openssl|paswd|paste|pathchk|perl|php|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|py|python[\d.]*|quota|quotachec|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|remsync|renae|renice|return|rev|rm|rmdir|rmmod|rsync|ruby|scp|screen|sdiff|sed|select|seq|set|sftp|sh|shift|shopt|shutdown|sleep|slocate|sort|source|split|sqlite3?|ssh|stat|strace|su|sudo|sum|susend|svn|sync|tail|tar|tcsh|tee|test|time|timeout|times|top|touch|tput|tr|tracerout|trap|true|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unset|unshar|unil|updatedb|uptime|useradd|userdel|usermod|users|uudecode|uuencode|vmstat|wait|watch|wc|wget|whatis|whereis|which|while|who|whoami|write|xargs|xdg-open|xz|yum|zip|zsh)\b' scope: keyword.other.shell - match: "[|!]" scope: keyword.operator.pipe.shell redirection: - match: '[><]\(' captures: 0: punctuation.definition.string.begin.shell push: - meta_scope: string.interpolated.process-substitution.shell - match: \) captures: 0: punctuation.definition.string.end.shell pop: true - include: main - match: '&>|\d*>&\d*|\d*(>>|>|<)|\d*<&|\d*<>' comment: "valid: &>word >&word >word [n]>&[n] [n]word [n]>>word [n]<&word (last one is duplicate)" scope: keyword.operator.redirect.shell string: - match: \\. scope: constant.character.escape.shell - match: "'" captures: 0: punctuation.definition.string.begin.shell push: - meta_scope: string.quoted.single.shell - match: "'" captures: 0: punctuation.definition.string.end.shell pop: true - match: \$?" captures: 0: punctuation.definition.string.begin.shell push: - meta_scope: string.quoted.double.shell - match: '"' captures: 0: punctuation.definition.string.end.shell pop: true - match: '\\[\$`"\\\n]' scope: constant.character.escape.shell - include: variable - include: interpolation - match: \$' captures: 0: punctuation.definition.string.begin.shell push: - meta_scope: string.quoted.single.dollar.shell - match: "'" captures: 0: punctuation.definition.string.end.shell pop: true - match: \\(a|b|e|f|n|r|t|v|\\|') scope: constant.character.escape.ansi-c.shell - match: '\\[0-9]{3}' scope: constant.character.escape.octal.shell - match: '\\x[0-9a-fA-F]{2}' scope: constant.character.escape.hex.shell - match: \\c. scope: constant.character.escape.control-char.shell support: - match: (?<=^|\s)(?::|\.)(?=\s|;|&|$) scope: support.function.builtin.shell - match: '(?