Править: Более новая версия с полным оглавлением как дерево и поддержка изображения, во второй части.
Используя \verbatiminput
от пакета дословно.
Как это:
#!/bin/bash
tempfile=$(mktemp /tmp/dirtree-XXXXX.tex)
trap "rm $tempfile" 0 1 2 3 6 9 15
cat <<EOF >$tempfile
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{fullpage,verbatim,dirtree}
\begin{document}
\section{Listing}
\dirtree{%
EOF
export -a scriptList=()
while IFS=/ read -a fPath ;do
file="${fPath[*]:${#fPath[*]}-1}"
IFS=/
full="${fPath[*]}"
type="$(file -b "$full")"
echo .${#fPath[@]} "${file//_/\\_}\DTcomment{$type}. "
[[ "$type" =~ script.text ]] && scriptList=("${scriptList[@]}" "$full")
done < <(
find $1 -type d -o -type f
) >>$tempfile
export IFS=$'\n\t '
echo "}" >>$tempfile
for file in "${scriptList[@]}";do
name="${file##*/}"
printf "\\section{%s}\n{\\\\scriptsize\\\\verbatiminput{%s}}\n" \
"${name//_/\_}" "${file}" >>"${tempfile}"
done
echo >>"${tempfile}" '\end{document}'
pdflatex -interaction nonstopmode "${tempfile}"
Кто произвел бы этот вид вывода:
NOTA: Для вычислений toc, latex
должны быть выполнены два раза.
ошибки:
Этот сценарий является только подтверждением концепции, тип изображений, вероятно, ограничен и мог быть улучшен, в конечном счете справкой imagemagik, netpbm или любого графического lib... и так далее
todo:
Такие вот дела:
#!/bin/bash
tempfile=$(mktemp /tmp/dirtree-XXXXX.tex)
# trap "rm $tempfile" 0 1 2 3 6 9 15
cat <<EOF >$tempfile
\documentclass[11pt,a4paper,oneside]{article}
\usepackage{fullpage,graphicx,verbatim,dirtree}
\makeatletter
\newcommand{\typePPage}[2]{\DTcomment{{\scriptsize #1
\begin{minipage}[t]{5em}\mbox{}\hfill\ifx\@empty#2\else%
s.$\ref{sec:#2}$, p.$\pageref{sec:#2}$\fi\end{minipage}}}}
\makeatother
\begin{document}\parindent=0pt%
\section{Listing}
\dirtree{%
EOF
export -a scriptList=()
export -A typelist=()
while IFS=/ read -a fPath ;do
file="${fPath[*]:${#fPath[*]}-1}"
IFS=/
full="${fPath[*]}"
type="$(file -b "$full")"
if [[ "$type" =~ script.text ]] || [[ "$type" =~ image ]] ;then
scriptList=("${scriptList[@]}" "$full")
typelist["${full//\//_}"]="$type"
echo .${#fPath[@]} \
"${file//_/\\_}\typePPage{$type}{${file//[\/.+()_-]/}}. "
else
echo .${#fPath[@]} "${file//_/\\_}\typePPage{$type}{}. "
fi
done < <(
find $1 -type d -o -type f
) >>$tempfile
export IFS=$'\n\t '
echo "}" >>$tempfile
for file in "${scriptList[@]}";do
name="${file##*/}"
printf '\\section{%s}\n\\label{sec:%s}\n' \
"${name//_/\_}" "${name//[\/.+()_-]/}"
if [[ "${typelist["${file//\//_}"]}" =~ script.text ]];then
printf '{\\scriptsize\\verbatiminput{%s}}\n' "${file}"
else
printf '\\includegraphics[width=\\textwidth]{%s}\n' "${file}"
fi
done >>"${tempfile}"
echo >>"${tempfile}" '\end{document}'
pdflatex -interaction nonstopmode "${tempfile}" >/dev/null 2>&1
pdflatex -interaction nonstopmode "${tempfile}"
Мог произвести:
Терминал GNOME (я думаю, что Linux Mint с Корицей использует терминал GNOME), имеет два переключателя командной строки для этого:
--load-config=FILE
Load a terminal configuration file
--save-config=FILE
Save the terminal configuration to a file
gnome-terminal --save-config=/path/to/the/file
сохранить текущее состояние в файл.gnome-terminal --load-config=/path/to/the/file
для загрузки конфигурации из файла, Вы сохранили конфигурацию.