Skip to content

Instantly share code, notes, and snippets.

@csloz
Created October 21, 2021 05:42
Show Gist options
  • Save csloz/8d2700fa63669a6419b469fcd518f942 to your computer and use it in GitHub Desktop.
Save csloz/8d2700fa63669a6419b469fcd518f942 to your computer and use it in GitHub Desktop.
Custom docker/ yml colouring for nano
#Create a custom yml colour scheme for nano
sudo tee /usr/share/nano/yaml.nanorc <<EOF >> /dev/null
# Supports files
syntax "YAML" "\.ya?ml$"
## Keywords
icolor red "^(FROM|MAINTAINER|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)[[:space:]]"
## Brackets & parenthesis
color brightgreen "(\(|\)|\[|\])"
## Double ampersand
color brightmagenta "&&"
## Comments
icolor cyan "^[[:space:]]*#.*$"
## Blank space at EOL
color ,green "[[:space:]]+$"
## Strings, single-quoted
color brightwhite "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!"
## Strings, double-quoted
color brightwhite ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!"
## Single and double quotes
color brightyellow "('|\")"
## Booleans
icolor brightcyan " (y|yes|n|no|true|false|on|off)$"
## Numbers
color brightred " [[:digit:]]+(\.[[:digit:]]+)?"
## Arrays
color red "\[" "\]" ":\s+[|>]" "^\s*- "
## Reserved
color green "(^| )!!(binary|bool|float|int|map|null|omap|seq|set|str) "
## Closed quotes
color yellow "['\"].*['\"]"
## Equal sign
color brightgreen ":( |$)"
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment