foo.tex:

\documentclass{...}
...
\usepackage{thumbindex}
\pagestyle{thumbindex}
...
\begin{document}
...
\mainmatter
\chapter{...}
...
\end{document}

thumbindex.sty:

%% Simple page style with thumb indices
%% usage:
%% \usepackage{thumbindex}
%% \pagestyle{thumbindex}

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{thumbindex}

\def\ps@thumbindex{ %
  \let\@oddfoot\@empty
  \let\@evenfoot\@empty
  \def\@evenhead{ %
    \if@mparswitch \hss \fi
    \underline{\hbox to \fullwidth{\autoxspacing
        \textbf{\thepage}\hfil\leftmark}}%
    \if@mparswitch\else \hss \fi}%
  \def\@oddhead{ %
    \underline{ %
      \hbox to \fullwidth{ %
        \autoxspacing
        {\if@twoside\rightmark\else\leftmark\fi}\hfil\textbf{\thepage}%
      }%
    }\hss
    % draw thumb index
    \if@mainmatter
    \@drawthumbindex{\c@chapter}{10truemm}{0.25}{0}
    \fi
    % end draw thumb index
  }%
  \let\@mkboth\markboth
  \def\chaptermark##1{\markboth{ %
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \@chapapp\thechapter\@chappos\hskip1zw
      \fi
    \fi
    ##1}{}}%
  \def\sectionmark##1{\markright{ %
    \ifnum \c@secnumdepth >\z@ \thesection \hskip1zw\fi
    ##1}}}%

% draw thumb index
% usage: \@drawthumbindex{COUNTER}{VADVANCE}{HOFFSET}{VOFFSET}
% e.g. \@drawthumbindex{\c@chapter}{10truemm}{0.25}{0}
\newcommand{\@drawthumbindex}[4]{ %
  \setlength\unitlength{#2}%
  \begin{picture}(0,#4)%
    \put(#3,-#1){ %
      \makebox(0,0)[tl]{ %
        \rule{10truemm}{1truemm}%
      }%
    }%
    \put(#3,-#1){ %
      \makebox(0,-.3)[tl]{ %
        \hb@xt@ 8truemm{\hfil\the#1\hfil}%
      }%
    }%
  \end{picture}%
}

(Remove space in “{ %” to restore correct code. There seems no way to escape Liquid markups yet: http://github.com/tobi/liquid/issues#issue/6.)