%% %% This is file `shdoc.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% shdoc.dtx (with options: `package') %% %% This is a generated file. %% %% Copyright 2016 Simon M. Laube %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 %% of this license or (at your option) any later version. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt %% and version 1.3 or later is part of all distributions of LaTeX %% version 2005/12/01 or later. %% %% This work has the LPPL maintenance status `author maintained'. %% %% The Current Maintainer of this work is S. M. Laube %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{shdoc}[2016/09/04 v2.1b Package for documenting shell operations] \RequirePackage[dvipsnames]{xcolor} \RequirePackage{float} \RequirePackage{caption} \RequirePackage{mdframed} \RequirePackage{kvoptions} \RequirePackage{relsize} \RequirePackage{stringstrings} \RequirePackage{ifthen} \makeatletter \DeclareStringOption[gray!70]{backgroundcolor} \DeclareStringOption[green!80!yellow]{usernamecolor} \DeclareStringOption[green!80!yellow]{machinenamecolor} \DeclareStringOption[RoyalBlue]{pathcolor} \DeclareStringOption[RoyalBlue]{indicatorcolor} \DeclareStringOption[green!80!yellow]{separatorcolor} \DeclareStringOption[white!60!gray]{optioncolor} \DeclareStringOption[black]{textcolor} \DeclareStringOption[\$]{indicatorsymbol} \DeclareStringOption[\~]{defaultpath} \DeclareStringOption[@]{separatorsymbol} \ProcessKeyvalOptions* \def\shpreset#1{\csname sh@preset@#1\endcsname}% \def\shpresetdef#1#2{% \expandafter\gdef\csname sh@preset@#1\endcsname{\shpreset{default} #2}% }% \def\shchange#1#2{\expandafter\gdef\csname shdoc@#1\endcsname{#2}} \let\shchangesymbol\shchange% \let\shchangecolor\shchange% \def\sh@preset@default{% \shchangecolor{backgroundcolor}{gray!70}% \shchangecolor{usernamecolor}{green!80!yellow}% \shchangecolor{machinenamecolor}{green!80!yellow}% \shchangecolor{pathcolor}{RoyalBlue}% \shchangecolor{indicatorcolor}{RoyalBlue}% \shchangecolor{separatorcolor}{green!80!yellow}% \shchangecolor{optioncolor}{white!60!gray}% \shchangecolor{textcolor}{black}% \shchangesymbol{indicatorsymbol}{\$}% \shchangesymbol{defaultpath}{\~}% \shchangesymbol{separatorsymbol}{@}% }% \shpresetdef{mint}{\shpreset{default}}% \shpresetdef{arrows}{% \shchangecolor{usernamecolor}{red}% \shchangecolor{machinenamecolor}{green!80!yellow}% \shchangecolor{separatorcolor}{white}% \shchangecolor{indicatorsymbol}{$\gg$}% \shchangecolor{indicatorcolor}{green!80!yellow}% \shchangecolor{backgroundcolor}{black}% \shchangecolor{textcolor}{white}% \shchangecolor{optioncolor}{gray}% }% \shpresetdef{darkblue}{% \definecolor{shdarkblue}{RGB}{7,75,138}% xcolor syntax \shchangecolor{backgroundcolor}{shdarkblue}% \shchangecolor{textcolor}{white}% \shchangecolor{separatorcolor}{white}% \shchangecolor{usernamecolor}{orange}% \shchangecolor{machinenamecolor}{orange}% \shchangecolor{pathcolor}{green!60!black}% \shchangecolor{optioncolor}{SkyBlue!80!black}% } \shpresetdef{blackwhite}{% \shchangecolor{backgroundcolor}{gray!30}% \shchangecolor{textcolor}{black}% \shchangecolor{separatorcolor}{black}% \shchangecolor{usernamecolor}{gray}% \shchangecolor{machinenamecolor}{gray}% \shchangecolor{pathcolor}{gray!50!black}% \shchangecolor{optioncolor}{white}% \shchangecolor{indicatorcolor}{white}% } \shpresetdef{airy}{% \shchangecolor{backgroundcolor}{SkyBlue!15}% \shchangecolor{usernamecolor}{Emerald}% \shchangecolor{machinenamecolor}{Emerald}% \shchangecolor{pathcolor}{orange!70}% \shchangecolor{indicatorcolor}{orange!70}% \shchangecolor{separatorcolor}{Emerald}% \shchangecolor{optioncolor}{Emerald!30}% } \newcounter{shlinenumber}% def new counter \setcounter{shlinenumber}{0}% set counter to 0 \let\@shlistname\relax% \gdef\shlistname#1{\gdef\@shlistname{#1}}% \shlistname{List of Terminal Sessions}% set default value \newfloat{sh}{tbph}{lsh}% define new float \restylefloat*{sh}% \floatstyle{plain}% set style \let\@shfloatname\relax% \gdef\shfloatname#1{\gdef\@shfloatname{#1}}% \shfloatname{Terminal~Session}% default float name \floatname{sh}{\@shfloatname}% \captionsetup[sh]{position=bottom}% \def\listofsh{\listof{sh}{\@shlistname}}% \let\@shuser\relax% \let\@shmachine\relax% \def\shuser#1{\gdef\@shuser{#1}}% \def\shmachine#1{\gdef\@shmachine{#1}}% \def\@default@shuser{root}% \def\@default@shmachine{linux}% \shuser{\@default@shuser}% \shmachine{\@default@shmachine}% \def\sh@lnscale{.7}% default number scaling \def\sh@fontcheck{% if fontsize < 6pt \ifthenelse{\f@size<6}{% \gdef\sh@lnscale{1}% factor = 1 }{% elif fontsize < 8pt \ifthenelse{\f@size<8}{% \gdef\sh@lnscale{.84}% factor = 0.84 }{% else: nothing }% }% }% \newlength{\sh@linenumberwidth}% \long\def\shline#1#2{ \ttfamily\sh@fontcheck\noindent% \ifnum\value{shlinenumber}<10% \textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}0\theshlinenumber}% \settowidth{\sh@linenumberwidth}{% \relscale{\sh@lnscale}0\theshlinenumber% }% \else% \textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}\theshlinenumber}% \settowidth{\sh@linenumberwidth}{% \relscale{\sh@lnscale}\theshlinenumber% }% \fi\hspace{\sh@linenumberwidth}% \hangindent=2\sh@linenumberwidth% \textcolor{\shdoc@usernamecolor}{\@shuser}% \textcolor{\shdoc@separatorcolor}{\shdoc@separatorsymbol}% \textcolor{\shdoc@machinenamecolor}{\@shmachine}% \ \ifx&% \textcolor{\shdoc@pathcolor}{\shdoc@defaultpath\ }% \textcolor{\shdoc@indicatorcolor}{\shdoc@indicatorsymbol} \else% \textcolor{\shdoc@pathcolor}{#1\ }% \textcolor{\shdoc@indicatorcolor}{\shdoc@indicatorsymbol}% \fi\ \textcolor{\shdoc@textcolor}{#2}% \stepcounter{shlinenumber}\par } \newlength{\sh@optionboxwidth} \long\def\shoutput#1#2{ \ttfamily\sh@fontcheck\noindent% \ifnum\value{shlinenumber}<10% \textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}0\theshlinenumber}% \settowidth{\sh@linenumberwidth}{% \relscale{\sh@lnscale}0\theshlinenumber% }% \else% \textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}\theshlinenumber}% \settowidth{\sh@linenumberwidth}{% \relscale{\sh@lnscale}\theshlinenumber% }% \fi\hspace{\sh@linenumberwidth}% \hangindent=2\sh@linenumberwidth% \ifx&% \textcolor{\shdoc@textcolor}{#2}\stepcounter{shlinenumber}% \settowidth{\sh@optionboxwidth}{0cm}% \else% \fcolorbox{\shdoc@optioncolor}% {\shdoc@optioncolor}{\textcolor{\shdoc@textcolor}{[#1]}}\ % \settowidth{\sh@optionboxwidth}{% \fcolorbox{\shdoc@optioncolor}% {\shdoc@optioncolor}{\textcolor{\shdoc@textcolor}{[#1]}}\ }% \addtolength{\hangindent}{\sh@optionboxwidth}% \textcolor{\shdoc@textcolor}{#2}\stepcounter{shlinenumber}% \fi\par% } \let\sh@autoformat\relax% \def\shautoformat#1{\gdef\sh@autoformat{#1}}% \shautoformat{false}% \let\sh@autopath\relax% \def\shautopath#1{\gdef\sh@autopath{#1}}% \shautopath{false}% \def\shpath{% \immediate\write18{pwd >shpath.tmp 2>&1}% \newread\sh@pathfile% \openin\sh@pathfile=shpath.tmp% \endlinechar=-1% \readline\sh@pathfile to \sh@path% \sh@path% \closein\sh@pathfile } \def\shread#1#2{% \newread\sh@inputfile% \openin\sh@inputfile=#2% \endlinechar=-1% hide the endlinechar (-1 is invalid, thus not printed) \begin{shbox}% \ifthenelse{\equal{#1}{}}{}% empty: do not print {% \ifthenelse{\equal{\sh@autopath}{true}}{% \shline{\shpath}{#1}% }{% \ifthenelse{\equal{\sh@autopath}{false}}{}% {\typeout{-----------------------------------------------}% \typeout{ Package shdoc info: I don't know what you}% \typeout{ mean when passing '\sh@autopath' to autopath}% \typeout{ and I'm going to ignore it and restore the}% \typeout{default 'false'} % \typeout{-----------------------------------------------}% \shautopath{false}}% \shline{}{#1}% }% } \loop\unless\ifeof\sh@inputfile% \readline\sh@inputfile to \sh@fileline% \ifeof\sh@inputfile% again check of eof prevents last blank line \else% \shoutput{}{\sh@fileline}% \fi% \repeat% \end{shbox}% \closein\sh@inputfile% } \def\shrun#1{% \ifthenelse{\equal{\sh@autoformat}{true}}{% \immediate\write18{#1 >shrun.tmp 2>&1}% \immediate\write18{./shreformat.sh}% \shread{#1}{shrun-formatted.tmp}% }{% \ifthenelse{\equal{\sh@autoformat}{false}}{}% {\typeout{-----------------------------------------------}% \typeout{ Package shdoc info: I don't know what you}% \typeout{ mean when passing '\sh@autoformat' to autoformat}% \typeout{ and I'm going to ignore it and restore the}% \typeout{default 'false'}% \typeout{-----------------------------------------------}% \shautoformat{false}}% \immediate\write18{#1 >shrun.tmp 2>&1}% \shread{#1}{shrun.tmp}% }% }% \def\shautoread#1#2{% \newread\sh@inputfile% \openin\sh@inputfile=#2% \endlinechar=-1% \begin{shbox} \ifthenelse{\equal{#1}{}}{% }{% \ifthenelse{\equal{\sh@autopath}{true}}{% \shline{\shpath}{#1}% }{% \ifthenelse{\equal{\sh@autopath}{false}}{}% {\typeout{-----------------------------------------------}% \typeout{ Package shdoc info: I don't know what you}% \typeout{ mean when passing '\sh@autopath' to autopath}% \typeout{ and I'm going to ignore it and restore the}% \typeout{default 'false'}% \typeout{-----------------------------------------------}% \shautopath{false}}% \shline{}{#1}% }% }% \loop\unless\ifeof\sh@inputfile% \readline\sh@inputfile to \sh@fileline% \ifeof\sh@inputfile% \else% \getnextword[e]{\sh@fileline}% \findchars[q]{\thestring}{-}% \ifthenelse{\equal{\theresult}{1}}{% \shoutput{\thestring}% {\stringlength[e]{\thestring}\gobblechars[v]{\sh@fileline}{\theresult}}% }{% \shoutput{}{\sh@fileline}% }% \fi% \repeat% \end{shbox}% \closein\sh@inputfile% }% \def\shautorun#1{ \ifthenelse{\equal{\sh@autoformat}{true}}{% \immediate\write18{#1 >shrun.tmp 2>&1}% \immediate\write18{./shreformat.sh}% \shautoread{#1}{shrun-formatted.tmp}% }{% \ifthenelse{\equal{\sh@autoformat}{false}}{}% {\typeout{-----------------------------------------------}% \typeout{ Package shdoc info: I don't know what you}% \typeout{ mean when passing '\sh@autoformat' to autoformat}% \typeout{ and I'm going to ignore it and restore the}% \typeout{default 'false'}% \typeout{-----------------------------------------------}% \shautoformat{false}}% \immediate\write18{#1 >shrun.tmp 2>&1}% \shautoread{#1}{shrun.tmp}% }% } \def\shclearfiles{ \immediate\write18{rm shrun.tmp; rm shrun-formatted.tmp; rm shpath.tmp} } \newmdenv[linecolor=white,backgroundcolor=\shdoc@backgroundcolor, settings=\setcounter{shlinenumber}{1}]{shbox} \makeatother \endinput %% %% End of file `shdoc.sty'.