Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitweb: How I see source code in tree view with color

Tags:

git

gitweb

I use gitweb.

In the tree view I see my source code. But this code is all in black, I like configurated to added highlight

like image 259
Pablo Morales Avatar asked Mar 30 '10 20:03

Pablo Morales


3 Answers

To enable syntax highlighting in 'blob' view in modern gitweb, you need

  1. Have highlight program installed (the one from 'highlight' package, not from 'source-highlight' or 'src-highlight'; they are different programs).

  2. Configure gitweb to enable source highlighting. This can be done by adding the following line

    $feature{'highlight'}{'default'} = [1];
    

    to gitweb configuration file for your installation, usually /etc/gitweb.conf.

    See "Configuring gitweb features" section in gitweb.conf manpage (and said manpage in general), the part about 'highlight' feature, or relevant lines in gitweb sources.

    Note: if you use gitweb with persistent web server environment, like mod_perl, FastCGI or PSGI, you might need to restart gitweb script if it is configured to read configuration only once.


Original response (historical)

It is currently not supported, but take a look at gitweb/web branch of my git/jnareb-git.git repository - those two commits adding syntax highlighting to gitweb were sent to git mailing list (as RFC = Request For Comments patches). Those patches use highlight tool from http://www.andre-simon.de/

You can try to cherry pick those two commits: 5f7b6461 and 4edcf10d.

like image 65
Jakub Narębski Avatar answered Nov 19 '22 17:11

Jakub Narębski


If you don't want to change the package files, an alternative to Todochangeusername procedure is to install highlight and then add to the bottom of the file /etc/gitweb.conf:

$feature{'highlight'}{'default'} = [1];

(without the \ escape character).

like image 16
Nuno Sucena Almeida Avatar answered Nov 19 '22 19:11

Nuno Sucena Almeida


  1. install at least git version 1.7.5 Ubuntu: https://launchpad.net/~git-core/+archive/ppa
  2. install gitweb and programm called highlight Ubuntu: sudo apt-get install gitweb highlight
  3. Add to the file: sudo vim /usr/lib/git-core/git-instaweb
    line 586: \$feature{'highlight'}{'default'} = [1];
like image 3
Todochangeusername Avatar answered Nov 19 '22 19:11

Todochangeusername