Сохраните представления в нескольких экранных терминалах

Расширение или улучшение кода Тердона на основе некоторой логики в этом Ответ

#!/usr/bin/env perl

## This is the path to the target  directories
my $path="/Users/Masi/Dropbox/";
chdir $path or die "cannot chdir '$path'";

## Iterate over the directories
foreach my $dir (
    "Cardiology", "Pathophysiology", "Patology and Biopsy", "Physiology",
    "Propedeutics", "Radiology", "Rheumatology", "Surgery"
)
{
    my $dd=0;
    ## Read the current directory
    opendir my $DIR, $dir or die "cannot opendir '$dir'";

    ## Find all files in this directory
    while (my $file = readdir($DIR)) {
        ## Reset the counter
        my $c=0;
        ## Skip any files that aren't .tex
        next unless $file =~ /\.tex$/;

        ## Open the file
        open(my $fh,"$path/$dir/$file");

        while (<$fh>) {
            ## Get the subsection. $_ is the current line.
            $sub="$_" and $n=0 if /\\subsection{/;
            ## If this line is a question
            if (/\\begin{question}/) {
                ## If this counter is 0, this is the first file
                ## of this directory, so print the section
                ## Print the section name
                if ($dd==0) {
                    print "\\section{$dir}\n\n";
                    $dd++;
                }
                ## If this counter is 0, this is the first question
                ## of this subsection, so print the subsection line
                print "$sub\n" if $n==0;

                $n++;
                ## Increment the counter, we want these lines
                $c++;
                ## And print
                print;
            }
            else {
                ## Print lines if the counter is 1
                print if $c==1;
                ## reset the counter to 0
                print "\n" and $c=0 if /\\end{question}/;
            }
        }
        print "\n";
    }
    closedir $DIR  or die "cannot closedir '$dir'";
}

, где я добавил некоторое управление ошибками.

1
05.08.2014, 10:19
1 ответ

В соответствии с предложенной ссылкой @jasonwryan, я создал следующий скрипт для решения моей проблемы;

cd dir1
tmux new-window -a -n WinSplit
tmux new-session -d -s WinSplit
tmux selectp -t WinSplit
tmux split-window -v
cd dir2
tmux select-pane -U
tmux split-window -h
cd dir3
tmux split-window -v
#tmux select-layout even-vertical
tmux attach -t WinSplit

tmux bind -n M-Left select-pane -L
tmux bind -n M-Right select-pane -R
tmux bind -n M-Up select-pane -U
tmux bind -n M-Down select-pane -D
0
28.01.2020, 01:54

Теги

Похожие вопросы