![누락된 경우에만 특정 이름으로 새 tmux 창을 엽니다.](https://linux55.com/image/133879/%EB%88%84%EB%9D%BD%EB%90%9C%20%EA%B2%BD%EC%9A%B0%EC%97%90%EB%A7%8C%20%ED%8A%B9%EC%A0%95%20%EC%9D%B4%EB%A6%84%EC%9C%BC%EB%A1%9C%20%EC%83%88%20tmux%20%EC%B0%BD%EC%9D%84%20%EC%97%BD%EB%8B%88%EB%8B%A4..png)
동일한 세션 내의 자체 tmux 창에서 여러 명령을 병렬로 실행하여 각 명령의 인스턴스 하나만 실행되도록 해야 합니다.
이상적으로 창은 쉽게 식별할 수 있도록 고정된 이름과 순서를 따라야 합니다.
나는 과거에 다음과 같은 일을 했다고 생각합니다.
tmux new-window -t cmd1 -n cmd1 { my command }
그런 다음 tmux는 마지막 세션에서 이름이 지정된 cmd1
첫 번째 위치(cmd2 등이 뒤따름)에 창을 생성하거나 창이 이미 존재하는 경우 아무 작업도 수행하지 않습니다.
답변1
실제 정수를 인덱스로 사용하면 나에게 적합합니다.
$ 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
정수가 아닌 인덱스의 경우 작동하지 않습니다.
$ tmux new-window -t cmd1 -n cmd1 -d sleep 60
can't find window i1
매뉴얼 페이지 인용문(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.