For those who use nano as their CLI editor of choice: Here’s a syntax highlighting file for Git commit messages which also supports the special KDE commit hook keywords.
## syntax highlighting for git commit messages of KDE projects
syntax "patch" ".git/COMMIT_EDITMSG$"
# overlong lines
color brightred "^.{70,}.+$"
# KDE commit hook keywords, see: http://community.kde.org/Sysadmin/GitKdeOrgManual#Commit_hook_keywords
color yellow "^(FEATURE|BUG|CCBUG|FIXED-IN|CCMAIL|REVIEW|GUI|DIGEST):.*$"
color yellow "(SVN_SILENT|GIT_SILENT|SVN_MERGE)"
# comment
color blue "^#.*$"
# special comment lines
color green "^# Changes to be committed:"
color red "^# Changes not staged for commit:"
color brightblue "^# Untracked files:"
color brightblue "^# On branch .+$"
color brightblue "^# Your branch is ahead of .+$"
# diff files
# meh - cannot match against \t ... should be: ^#\t.*$
color cyan "^#[^ a-zA-Z0-9][^ ].*$"
continue reading...
Use the snippet below in your ~/.nanorc
or /etc/nanorc
file to highlight *.ini
files like php.ini
in Nano.
# ini highlighting
syntax "ini" "\.ini(\.old|~)?$"
# values
color brightred "=.*$"
# equal sign
color green "="
# numbers
color brightblue "-?[0-9\.]+\s*($|;)"
# ON/OFF
color brightmagenta "ON|OFF|On|Off|on|off\s*($|;)"
# sections
color brightcyan "^\s*\[.*\]"
# keys
color cyan "^\s*[a-zA-Z0-9_\.]+"
# comments
color brightyellow ";.*$"
continue reading...
When I’m messing around with config files on the command line my editor of choice is Nano. It’s simple, fast and pretty much straight forward. You don’t have to learn any commands and can use keyboard shortcuts just like in GUI programs.
Settings
Today I had a look on the project website and saw that there are tons of settings which I really missed before. Just have a look into your /etc/nanorc
for a default config file with all settings and their default values. Here are those I like most:
- smooth (scrolling)
- autoindent
- mouse (though I use it rarely)
- smarthome
- tabsize (8 is far to much, I love 4)
Syntax Highlighting
Yes! Nano supports syntax highlighting! And I never knew it, but heck - it’s never to late. Not for neat features like this one, though I really wonder why this is not activated by default…
In the aforementioned /etc/nanorc
are already some default languages which just wait to be commented out. You might also want to have a look into /usr/share/nano
, there are some languages you can include in your nanorc
file with:
continue reading...
And here another syntax file for Nano. This time it highlights the /etc/apt/sources.list
:
## syntax highlighting for /etc/apt/sources.list
syntax "apt/sources.list" "sources\.list(\.old|~)?$"
# component
color brightmagenta "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+ .+$"
# distribution
color brightred "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+"
# URI
color brightgreen "(http|file|ftp):/[^ ]+"
# cdroms
# [^\]] does not work…
color brightgreen "cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/"
# deb / deb-src
color cyan "^deb"
color brightblue "^deb-src"
# comments
color brightyellow "#.*"
continue reading...