{{ define "main" }}
{{ $env := printf "%s@%s:~/%s$" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName "" | safeHTML }}
{{ $envWithDir := printf "%s@%s:~/%s$" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName .Site.Params.Terminal.workDir | safeHTML }}
{{ $cd := printf "cd %s" .Site.Params.Terminal.workDir | safeHTML }}
{{ $cat := printf "cat %s" .Site.Params.Terminal.profile | safeHTML }}
{{ $description := "" }}
{{ if eq (substr .Site.Params.Terminal.description -3 3) ".md" }}
{{ $s := "" }}
{{ with .Site.GetPage .Site.Params.Terminal.description }}
{{ $s = replaceRE "?p[^>]*>" "" .Content 1 }}
{{ end }}
{{ $description = printf "%s" $s | safeHTML}}
{{ else }}
{{ $limit := sub (len (findRE "\n" .Site.Params.Terminal.description)) 1 }}
{{ $description = printf "%s" .Site.Params.Terminal.description }}
{{ $description = replaceRE "\n" "
" $description $limit| safeHTML }}
{{ end }}
{{ $tree := "" }}
{{ $leaf := "" }}
{{ if .Site.Params.Tree.use }}
{{ $tree = printf "tree ./%s/" .Site.Params.Tree.folderName | safeHTML}}
{{ $leaf = printf "%s./%s/
" $leaf .Site.Params.Tree.folderName | safeHTML}}
{{ range $index, $val := .Site.Params.Tree.files }}
{{ $ac := index $val 0}}
{{ $link := index $val 1}}
{{ $l := $.Site.GetPage $link }}
{{ if $l }}
{{ $link = $l.Permalink}}
{{ end }}
{{ if eq (add $index 1) (len $.Site.Params.Tree.files) }}
{{ $leaf = printf "%s└── %s" $leaf $link $ac $ac | safeHTML}}
{{ else }}
{{ $leaf = printf "%s├── %s
" $leaf $link $ac $ac | safeHTML}}
{{ end }}
{{ end }}
{{ end }}
{{ $end := $env }}
{{ $payload := delimit (slice $cd $cat $description $tree $leaf $end) "" }}
{{ $ps1Delay := $.Site.Params.Terminal.ps1Delay }}
{{ $stdoutDelay := $.Site.Params.Terminal.stdoutDelay }}
{{ $commandDelay := $.Site.Params.Terminal.commandDelay }}
{{ partial "partials/typeIndex.html" (dict "context" . "env" $env "cd" $cd "envWithDir" $envWithDir "cat" $cat "description" $description "tree" $tree "leaf" $leaf "ps1delay" $ps1Delay "stdoutdelay" $stdoutDelay "commanddelay" $commandDelay ) }}