ពាក្យបញ្ជាផ្ទាល់ខ្លួន

កំណត់ពាក្យបញ្ជាផ្ទាល់ខ្លួននិងប្លង់ workspace ដោយបន្ថែមឯកសារ cmux.json ទៅឫសគម្រោងរបស់អ្នក ឬ ~/.config/cmux/។ ពាក្យបញ្ជាលេចឡើងក្នុងបន្ទះពាក្យបញ្ជា។

ទីតាំងឯកសារ

cmux រកការកំណត់រចនាសម្ព័ន្ធនៅ២កន្លែង:

  • តាមគម្រោង: ./cmux.jsonស្ថិតក្នុងថតគម្រោងរបស់អ្នក, មានអាទិភាព
  • សាកល: ~/.config/cmux/cmux.jsonអនុវត្តចំពោះគម្រោងទាំងអស់, បំពេញពាក្យបញ្ជាដែលមិនបានកំណត់ក្នុងតំបន់
ពាក្យបញ្ជាក្នុងតំបន់បដិសេធពាក្យបញ្ជាសាកលដែលមានឈ្មោះដូចគ្នា។

ការផ្លាស់ប្ដូរត្រូវបានទទួលស្គាល់ដោយស្វ័យប្រវត្តិ — មិនចាំបាច់ចាប់ផ្ដើមឡើងវិញ។

ស្គីម៉ា

ឯកសារ cmux.json មានអារ៉េ commands។ ពាក្យបញ្ជានីមួយៗគឺជាពាក្យបញ្ជា shell សាមញ្ញ ឬនិយាមព workspace ពេញលេញ:

cmux.json
{
  "commands": [
    {
      "name": "Start Dev",
      "keywords": ["dev", "start"],
      "workspace": { ... }
    },
    {
      "name": "Run Tests",
      "command": "npm test",
      "confirm": true
    }
  ]
}

ពាក្យបញ្ជាសាមញ្ញ

ពាក្យបញ្ជាសាមញ្ញដំណើរការពាក្យបញ្ជា shell ក្នុងទែមីណាល​ដែលបានផ្ដោតបច្ចុប្បន្ន:

cmux.json
{
  "commands": [
    {
      "name": "Run Tests",
      "keywords": ["test", "check"],
      "command": "npm test",
      "confirm": true
    }
  ]
}

វាល

  • nameបង្ហាញក្នុងបន្ទះពាក្យបញ្ជា (ចាំបាច់)
  • descriptionការពិពណ៌នាជាជម្រើស
  • keywordsពាក្យស្វែងរកបន្ថែមសម្រាប់បន្ទះពាក្យបញ្ជា
  • commandពាក្យបញ្ជា shell ដំណើរការក្នុងទែមីណាល​ដែលបានផ្ដោត
  • confirmបង្ហាញប្រអប់បញ្ជាក់មុននឹងដំណើរការ

ពាក្យបញ្ជាសាមញ្ញដំណើរការក្នុងថតការងារបច្ចុប្បន្នរបស់ terminal ដែលកំពុងផ្ដោត។ ប្រសិនបើពាក្យបញ្ជារបស់អ្នកពឹងផ្អែកលើផ្លូវទាក់ទងនឹងគម្រោង សូមបន្ថែមពីមុខ cd "$(git rev-parse --show-toplevel)" && ដើម្បីដំណើរការពីឫសនៃ repo ឬ cd /your/path && សម្រាប់ថតណាមួយជាក់លាក់។

ពាក្យបញ្ជា workspace

ពាក្យបញ្ជា workspace បង្កើត workspace ថ្មីជាមួយប្លង់ផ្ទាល់ខ្លួននៃការបំបែក, ទែមីណាល, និងបន្ទះកម្មវិធីរុករក:

cmux.json
{
  "commands": [
    {
      "name": "Dev Environment",
      "keywords": ["dev", "fullstack"],
      "restart": "confirm",
      "workspace": {
        "name": "Dev",
        "cwd": ".",
        "layout": {
          "direction": "horizontal",
          "split": 0.5,
          "children": [
            {
              "pane": {
                "surfaces": [
                  {
                    "type": "terminal",
                    "name": "Frontend",
                    "command": "npm run dev",
                    "focus": true
                  }
                ]
              }
            },
            {
              "pane": {
                "surfaces": [
                  {
                    "type": "terminal",
                    "name": "Backend",
                    "command": "cargo watch -x run",
                    "cwd": "./server",
                    "env": { "RUST_LOG": "debug" }
                  }
                ]
              }
            }
          ]
        }
      }
    }
  ]
}

វាល workspace

  • nameឈ្មោះផ្ទាំង workspace (លំនាំដើមគឺឈ្មោះពាក្យបញ្ជា)
  • cwdថតការងារសម្រាប់ workspace
  • colorពណ៌ផ្ទាំង workspace
  • layoutដើមប្លង់ដែលកំណត់ការបំបែកនិងបន្ទះ

ឥរិយាបថចាប់ផ្ដើមឡើងវិញ

គ្រប់គ្រងអ្វីដែលកើតឡើងនៅពេល workspace ដែលមានឈ្មោះដូចគ្នារួចមានស្រាប់:

  • "ignore"ប្ដូរទៅ workspace ដែលមានស្រាប់ (លំនាំដើម)
  • "recreate"បិទហើយបង្កើតឡើងវិញដោយមិនសួរ
  • "confirm"សួរអ្នកប្រើប្រាស់មុននឹងបង្កើតឡើងវិញ

ដើមប្លង់

ដើមប្លង់កំណត់របៀបដែលបន្ទះត្រូវបានរៀបចំដោយប្រើថ្នាំងការបំបែករៀងគ្នា:

ថ្នាំងការបំបែក

ចែកចន្លោះទៅជាកូន២:

  • direction"horizontal" "vertical"
  • splitទីតាំងខ្សែបំបែកពី 0.1 ដល់ 0.9 (លំនាំដើម 0.5)
  • childrenថ្នាំងកូនពិតប្រាកដ២ (ការបំបែក ឬបន្ទះ)

ថ្នាំងបន្ទះ

ថ្នាំងស្លឹកមួយដែលមាន surface មួយ ឬច្រើន (ផ្ទាំងនៅក្នុងបន្ទះ)។

និយាម surface

surface នីមួយៗក្នុងបន្ទះអាចជាទែមីណាល​ ឬកម្មវិធីរុករក:

  • type"terminal" "browser"
  • nameចំណងជើងផ្ទាំងផ្ទាល់ខ្លួន
  • commandពាក្យបញ្ជា shell ដំណើរការដោយស្វ័យប្រវត្តិពេលបង្កើត (ទែមីណាល​តែប៉ុណ្ណោះ)
  • cwdថតការងារសម្រាប់ surface នេះ
  • envអថេរបរិស្ថានជាគូ key-value
  • urlURL ដែលត្រូវបើក (កម្មវិធីរុករកតែប៉ុណ្ណោះ)
  • focusផ្ដោតលើ surface នេះបន្ទាប់ពីបង្កើត

ការដោះស្រាយថតការងារ

  • . លុបចោលថតការងារ workspace
  • ./subdirទាក់ទងនឹងថតការងារ workspace
  • ~/pathពង្រីកទៅថតផ្ទះ
  • ផ្លូវដាច់ខាតប្រើដូចដែលមាន

ឧទាហរណ៍ពេញលេញ

cmux.json
{
  "commands": [
    {
      "name": "Web Dev",
      "description": "Docs site with live preview",
      "keywords": ["web", "docs", "next", "frontend"],
      "restart": "confirm",
      "workspace": {
        "name": "Web Dev",
        "cwd": "./web",
        "color": "#3b82f6",
        "layout": {
          "direction": "horizontal",
          "split": 0.5,
          "children": [
            {
              "pane": {
                "surfaces": [
                  {
                    "type": "terminal",
                    "name": "Next.js",
                    "command": "npm run dev",
                    "focus": true
                  }
                ]
              }
            },
            {
              "direction": "vertical",
              "split": 0.6,
              "children": [
                {
                  "pane": {
                    "surfaces": [
                      {
                        "type": "browser",
                        "name": "Preview",
                        "url": "http://localhost:3777"
                      }
                    ]
                  }
                },
                {
                  "pane": {
                    "surfaces": [
                      {
                        "type": "terminal",
                        "name": "Shell",
                        "env": { "NODE_ENV": "development" }
                      }
                    ]
                  }
                }
              ]
            }
          ]
        }
      }
    },
    {
      "name": "Debug Log",
      "description": "Tail the debug event log from the running dev app",
      "keywords": ["log", "debug", "tail", "events"],
      "restart": "ignore",
      "workspace": {
        "name": "Debug Log",
        "layout": {
          "direction": "horizontal",
          "split": 0.5,
          "children": [
            {
              "pane": {
                "surfaces": [
                  {
                    "type": "terminal",
                    "name": "Events",
                    "command": "tail -f /tmp/cmux-debug.log",
                    "focus": true
                  }
                ]
              }
            },
            {
              "pane": {
                "surfaces": [
                  {
                    "type": "terminal",
                    "name": "Shell"
                  }
                ]
              }
            }
          ]
        }
      }
    },
    {
      "name": "Setup",
      "description": "Initialize submodules and build dependencies",
      "keywords": ["setup", "init", "install"],
      "command": "./scripts/setup.sh",
      "confirm": true
    },
    {
      "name": "Reload",
      "description": "Build and launch the debug app tagged to the current branch",
      "keywords": ["reload", "build", "run", "launch"],
      "command": "./scripts/reload.sh --tag $(git branch --show-current)"
    },
    {
      "name": "Run Unit Tests",
      "keywords": ["test", "unit"],
      "command": "./scripts/test-unit.sh",
      "confirm": true
    }
  ]
}