Ich wurde gefragt, wie ich den user und den hostname in meinen Code-Umgebungen bunt bekomme. Ich benutze für das Syntaxhighlighting das Plugin WP-Syntax. Dieses wiederrum nutzt GeSHi im Hintergrund.
Damit der Hostname bunt wird, habe ich die Syntax der bash etwas erweitert. Dazu habe ich in der Datei wp-content/plugins/wp-syntax/geshi/geshi ein paar Zeilen hinzu gefügt:
language_data = array (
'LANG_NAME' => 'Bash',
// Bash DOES have single line comments with # markers. But bash also has
// the $# variable, so comments need special handling (see sf.net
// 1564839)
'COMMENT_SINGLE' => array('#'),
'COMMENT_MULTI' => array(),
'COMMENT_REGEXP' => array(
//Variables
1 => "/\\$\\{[^\\n\\}]*?\\}/i",
//BASH-style Heredoc
2 => '/<<-?\s*?(\'?)([a-zA-Z0-9]+)\1\\n.*\\n\\2(?![a-zA-Z0-9])/siU',
//Escaped String Starters
3 => "/\\\\['\"]/siU",
4 => "/(root@[a-z]+)/i", // root hat sich angemeldet
5 => "/([a-z]+@[a-z]+)/i" // ein normaler User hat sich angemeldet
),
....
'STYLES' => array(
'KEYWORDS' => array(
1 => 'color: #000000; font-weight: bold;',
2 => 'color: #c20cb9; font-weight: bold;',
3 => 'color: #7a0874; font-weight: bold;'
),
'COMMENTS' => array(
0 => 'color: #666666; font-style: italic;',
1 => 'color: #800000;',
2 => 'color: #cc0000; font-style: italic;',
3 => 'color: #000000; font-weight: bold;',
4 => 'color: #FF0000; font-weight: bold;', // Farbe und Font für root
5 => 'color: #0000FF; font-weight: bold;' // Farbe und Font für einen normalen User
),
...
Es handelt sich hierbei um einen Hack. Wenn man das Plugin updatet, muss man diese Änderung wieder vornehmen.