[Tex/LaTex] TikZ arrow tips on every subpath

tikz-arrowstikz-pgf

I would like to draw a single path with relative coordinates, where every segment gets their arrow tips. I have tried

\draw[<->] (0,0) -- ++(1,0) -- ++(1,0) -- ++(1,0);

But of course, as is specified in the manual, this adds arrow tips to the first and last subpaths only, of course, so it becomes something like <------------>, whereas I would like it to be <---><---><--->.
I have read Drawing an arrow tip to every node of a path and know that an edge will give me arrow tips on every edge, but then I can't use incremental coordinates.
(I am actually trying to do the exact same thing that @quinmars is doing in that question.)

Since the answer to that question is 5 years old, I was hoping that either TikZ or somebody else may have an elegant solution to this?

Best Answer

For straight lines only, maybe a bit like this?

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations}
\pgfdeclaredecoration{arrows}{draw}{
\state{draw}[width=\pgfdecoratedinputsegmentlength]{%
  \path [every arrow subpath/.try] \pgfextra{%
    \pgfpathmoveto{\pgfpointdecoratedinputsegmentfirst}%
    \pgfpathlineto{\pgfpointdecoratedinputsegmentlast}%
   };
}}
\tikzset{every arrow subpath/.style={->, draw, thick}}
\begin{document}
\begin{tikzpicture}
  \path [decoration=arrows, decorate](0,0) -- ++(1,0) -- ++(0,1) -- ++(45:1);
\end{tikzpicture}
\end{document}

enter image description here