{
  "slug": "Using-Tmux-to-startup-command-run-when-development-software-e63a5f106805",
  "title": "Using Tmux to startup command run when development software",
  "subtitle": "Nowadays, Microservices are very popular, and many companies and developers switched to this kind of technology. One of the problems ا have…",
  "excerpt": "Nowadays, Microservices are very popular, and many companies and developers switched to this kind of technology. One of the problems ا have…",
  "date": "2022-08-03",
  "tags": [
    "Microservices"
  ],
  "readingTime": "1 min",
  "url": "https://medium.com/@mobinshaterian/using-tmux-to-startup-command-run-when-development-software-e63a5f106805",
  "hero": "https://cdn-images-1.medium.com/max/800/1*Sd1G3r7caSafwve_BLr4JQ.png",
  "content": [
    {
      "type": "paragraph",
      "html": "Nowadays, Microservices are very popular, and many companies and developers switched to this kind of technology. One of the problems ا have in the morning is that I should open many terminals and use many docker-compose to run my project. In this article, I introduce the Tmux setting that can easily handle this problem."
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*Sd1G3r7caSafwve_BLr4JQ.png",
      "alt": "Tmux https://www.perl.com/article/an-introduction-to-tmux/",
      "caption": "Tmux https://www.perl.com/article/an-introduction-to-tmux/",
      "width": 889,
      "height": 493
    },
    {
      "type": "paragraph",
      "html": "As you know, first install Tmux on Ubuntu or any kind of OS that you use every day."
    },
    {
      "type": "paragraph",
      "html": "The below link shows a cheat sheet of Tmux exists, and that is so valuable."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Install Tmux"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\napt  install tmux"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "List of sessions exists in Tmux"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "tmux ls"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Delete session in Tmux"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "tmux kill-ses -t history"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Open session in Tmux"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "tmux atmux a -t mysession"
    },
    {
      "type": "paragraph",
      "html": "I wrote a bash script that is open six different folders in Tmux."
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "#!/bin/shtmux new-session -s service   -n Document -d 'cd /path/1 ; bash -i'tmux new-window  -t\nservice:1 -n micro       'cd /path/2 ; bash -i'tmux new-window  -t service:2 -n kafka\n'cd /path/3 ; bash -i'tmux new-window  -t service:3 -n mongoDb     'cd /path/4 ; bash -i'tmux\nnew-window  -t service:4 -n elk         'cd /path/5 ; bash -i'tmux new-window  -t service:5 -n db\n'cd /path/6 ; bash -i'tmux select-window -t service:1tmux -2 attach-session -t service"
    },
    {
      "type": "paragraph",
      "html": "Or It’s possible to run another command, such as docker-compose up in the default command."
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "#!/bin/shtmux new-session -s service   -n Document -d 'cd /path/1 ; bash -i'tmux new-window  -t\nservice:1 -n micro       'cd /path/2 ;\ndocker-compose up ; bash -i'tmux new-window  -t service:2 -n kafka       'cd /path/3 ; bash\n-i'tmux new-window  -t service:3 -n mongoDb     'cd /path/4 ; bash\n-i'tmux new-window  -t service:4 -n elk         'cd /path/5 ; bash\n-i'tmux new-window  -t service:5 -n db          'cd /path/6 ; bash\n-i'tmux select-window -t service:1tmux -2 attach-session -t service"
    },
    {
      "type": "paragraph",
      "html": "Finally, I save this config as&nbsp;./start.sh and add permission. At last, I run the file every morning day."
    }
  ]
}
