Current condition
A long URL makes a bad look as follows.

\documentclass{article}
\usepackage{xcolor,listings}
\lstset
{
language={[LaTeX]TeX},
backgroundcolor=\color{yellow!50},
breaklines=true,
}
\usepackage[colorlinks]{hyperref}
\def\InputCode#1#2{%
\lstinputlisting[caption=\href{#2}{#2}]{#1}}
\begin{document}
\minipage{0.5\linewidth}
\InputCode{\jobname.tex}{http://www.oakfurniturehouse.co.uk/userfiles/image/3B4K1820.jpg}
\endminipage
\end{document}
Expected Result
I want to trim the left part up to a certain length measured from the right as follows. The trimmed part will be replaced by ....

How to do this automatically because the minipage width can vary throughout my document.
gobbleleftor a simple optional argument which required a number? – Marco Daniel Sep 01 '12 at 09:27\linewidth-2\sideoffsetwhere\sideoffsetis used to make the URL look centered rather than fully justified. – kiss my armpit Sep 01 '12 at 09:34