Abra a nova janela do tmux com nome específico somente se estiver faltando

1

Eu preciso lançar vários comandos em paralelo, cada um em sua própria janela tmux na mesma sessão, certificando-se de que haja apenas uma instância de cada comando em execução.

O ideal é que as janelas sigam uma nomenclatura e uma ordem fixas para facilitar sua identificação.

Eu acho que no passado eu costumava fazer algo assim:

tmux new-window -t cmd1 -n cmd1 { my command }

Em seguida, o tmux criaria uma janela na última sessão, denominada cmd1 e na primeira posição (seguida por cmd2 etc.), ou não faria nada se a janela já existisse.

    
por Nemo 22.05.2018 / 12:44

1 resposta

0

Funciona para mim se eu usar um inteiro real como índice: $ tmux new-window -t 1 -n cmd1 -d sleep 60 $ tmux new-window -t 1 -n cmd1 -d sleep 60 create window failed: index in use: 1

Com um índice não inteiro, não funcionará: $ tmux new-window -t cmd1 -n cmd1 -d sleep 60 can't find window i1

Cotação da página man (tmux 2.5-4):

 new-window [-adkP] [-c start-directory] [-F format] [-n window-name] [-t target-window] [shell-command]
               (alias: neww)
         Create a new window.  With -a, the new window is inserted at the next index up from the specified target-window, moving windows up if necessary, otherwise target-window is the new window location.

         If -d is given, the session does not make the new window the current window.  target-window represents the window to be created; if the target already exists an error is shown, unless the -k flag is used, in which case it is destroyed.
    
por 22.05.2018 / 12:44

Tags