{"id":907,"date":"2021-05-31T13:24:49","date_gmt":"2021-05-31T06:24:49","guid":{"rendered":"http:\/\/www.oopsbox.com\/?p=907"},"modified":"2021-05-31T13:24:49","modified_gmt":"2021-05-31T06:24:49","slug":"tmux-starts-up-with-specified-windows-and-split-pane","status":"publish","type":"post","link":"https:\/\/www.oopsbox.com\/?p=907","title":{"rendered":"tmux starts up with specified windows and split pane"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/tmux\/tmux\">tmux<\/a> \u0e04\u0e37\u0e2d terminal multiplexer \u0e04\u0e33\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e40\u0e15\u0e47\u0e21 \u0e46 \u0e01\u0e47\u0e15\u0e32\u0e21\u0e19\u0e35\u0e49<\/p>\n<blockquote><p>tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.<\/p><\/blockquote>\n<p>\u0e40\u0e27\u0e25\u0e32\u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e01\u0e47\u0e04\u0e48\u0e2d\u0e22\u0e21\u0e32\u0e2a\u0e23\u0e49\u0e32\u0e07 Window \u0e2b\u0e23\u0e37\u0e2d Split Horizontal\/Vertical \u0e15\u0e32\u0e21\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 \u0e2a\u0e19\u0e43\u0e08\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21\u0e01\u0e47\u0e2d\u0e48\u0e32\u0e19\u0e15\u0e48\u0e2d\u0e44\u0e14\u0e49<a href=\"https:\/\/github.com\/tmux\/tmux\/wiki\/Getting-Started\">\u0e17\u0e35\u0e48\u0e19\u0e35\u0e48<\/a> \u0e2a\u0e48\u0e27\u0e19\u0e15\u0e48\u0e32\u0e07 \u0e46 \u0e02\u0e2d\u0e07 tmux \u0e15\u0e32\u0e21\u0e19\u0e35\u0e49<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-908\" src=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/tmux_pane_diagram.png\" alt=\"\" width=\"836\" height=\"570\" srcset=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/tmux_pane_diagram.png 836w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/tmux_pane_diagram-300x205.png 300w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/tmux_pane_diagram-768x524.png 768w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/tmux_pane_diagram-700x477.png 700w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><\/p>\n<p>\u0e41\u0e15\u0e48\u0e16\u0e49\u0e32\u0e40\u0e23\u0e32\u0e21\u0e35\u0e41\u0e1e\u0e17\u0e40\u0e17\u0e34\u0e23\u0e4c\u0e19\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e2d\u0e22\u0e39\u0e48\u0e41\u0e25\u0e49\u0e27\u0e01\u0e47\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e1b\u0e47\u0e19 Shell script \u0e2a\u0e31\u0e49\u0e19 \u0e46 \u0e44\u0e14\u0e49 \u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e40\u0e0a\u0e48\u0e19<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/bin\/bash\r\n\r\ncurrentsession=$(tmux display-message -p '#S')\r\nsession=\"$1\"\r\n\r\nfunction has-session {\r\n  tmux has-session -t $session 2&gt;\/dev\/null\r\n}\r\n\r\nif has-session ; then\r\n  tmux list-sessions\r\n  read -p \"Session already exists. [A]ttach\/[K]ill\/Kill [S]erver?\" -i Y input \r\n  case $input in  \r\n    a|A)\r\n      # Attach to created session\r\n      tmux attach-session -t $session\r\n      ;;\r\n    k|K)\r\n      tmux kill-session -t $session\r\n      ;; \r\n    s|S)\r\n      tmux kill-server\r\n      ;; \r\n    *) echo \"What?\" ;;\r\n  esac\r\nelse\r\n  tmux new-session -d -s $session -n 'home' 'cd ~; bash -i'\r\n  tmux new-window -a -t $session -n 'server' 'bash -i'\r\n  tmux new-window -a -t $session -n 'server-log'  'bash -i'\r\n\r\n  tmux select-window -t $session:1 \\; split-window -h \\; select-pane -t 1 \\; split-window -v \\; select-pane -t 3 \\; split-window -v \\; select-pane -t 1 \\;\r\n  tmux select-window -t $session:2 \\; split-window -h \\; split-window -v \\; select-pane -t 1 \\;\r\n  tmux select-window -t $session:3 \\; split-window -h \\; split-window -v \\; split-window -v \\; select-pane -t 2 \\; split-window -v \\; select-pane -t 1 \\;\r\n  \r\n  # Attach to created session\r\n  tmux attach-session -t $session\r\nfi<\/pre>\n<p>\u0e08\u0e30\u0e40\u0e23\u0e35\u0e22\u0e01 Shell script \u0e40\u0e2d\u0e07\u0e01\u0e47\u0e44\u0e14\u0e49\u0e2b\u0e23\u0e37\u0e2d\u0e08\u0e30\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e40\u0e1b\u0e47\u0e19 alias \u0e43\u0e19 <code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">.bashrc\/.zshrc<\/code>\u0e15\u0e32\u0e21\u0e2a\u0e30\u0e14\u0e27\u0e01 \u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e01\u0e47\u0e15\u0e32\u0e21\u0e19\u0e35\u0e49<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-909\" src=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1-1024x576.png\" alt=\"\" width=\"700\" height=\"394\" srcset=\"https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1-1024x576.png 1024w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1-300x169.png 300w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1-768x432.png 768w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1-1536x864.png 1536w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1-700x394.png 700w, https:\/\/www.oopsbox.com\/wp-content\/uploads\/Screenshot-20210531132003-1920x1080-1.png 1920w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>\u0e08\u0e1a\u0e1b\u0e34\u0e4a\u0e07 !!<\/p>\n<div id=\"s-share-buttons\" class=\"\"><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"fb-share-button\" data-href=\"https:\/\/www.oopsbox.com\/?p=907\" data-type=\"button_count\"><\/div><\/div><div class=\"s-single-share\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\"><\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"g-plusone\" data-size=\"medium\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"\/\/www.pinterest.com\/pin\/create\/button\/\" data-pin-do=\"buttonBookmark\"  data-pin-color=\"red\"><img decoding=\"async\" src=\"\/\/assets.pinterest.com\/images\/pidgets\/pinit_fg_en_rect_red_20.png\" \/><\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<script type=\"text\/javascript\" async defer src=\"\/\/assets.pinterest.com\/js\/pinit.js\"><\/script>\n\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"mailto:?Subject=tmux%20starts%20up%20with%20specified%20windows%20and%20split%20pane&Body=Here%20is%20the%20link%20to%20the%20article:%20https:\/\/www.oopsbox.com\/?p=907\" title=\"Email\" class=\"s3-email\"><img decoding=\"async\" src=\"https:\/\/www.oopsbox.com\/wp-content\/plugins\/simple-social-share\/includes\/..\/images\/share-email.png\"><\/a>\n\t\t\t\t\t\t\t\t\t\t\t<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>tmux \u0e04\u0e37\u0e2d terminal multiplexer \u0e04\u0e33\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22\u0e40\u0e15\u0e47\u0e21 \u0e46 \u0e01\u0e47\u0e15\u0e32\u0e21\u0e19\u0e35\u0e49 tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached. \u0e40\u0e27\u0e25\u0e32\u0e40\u0e23\u0e32\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e01\u0e47\u0e04\u0e48\u0e2d\u0e22\u0e21\u0e32\u0e2a\u0e23\u0e49\u0e32\u0e07 Window \u0e2b\u0e23\u0e37\u0e2d Split Horizontal\/Vertical \u0e15\u0e32\u0e21\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 \u0e2a\u0e19\u0e43\u0e08\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21\u0e01\u0e47\u0e2d\u0e48\u0e32\u0e19\u0e15\u0e48\u0e2d\u0e44\u0e14\u0e49\u0e17\u0e35\u0e48\u0e19\u0e35\u0e48 \u0e2a\u0e48\u0e27\u0e19\u0e15\u0e48\u0e32\u0e07 \u0e46 \u0e02\u0e2d\u0e07 tmux &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.oopsbox.com\/?p=907\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;tmux starts up with specified windows and split pane&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":910,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[10,117],"class_list":["post-907","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-shell-script","tag-tmux","entry"],"views":2607,"_links":{"self":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=907"}],"version-history":[{"count":1,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/907\/revisions"}],"predecessor-version":[{"id":911,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/907\/revisions\/911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/media\/910"}],"wp:attachment":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}