Compare commits

..

No commits in common. "main" and "v0.0.4-screen" have entirely different histories.

6 changed files with 3 additions and 60 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -11,7 +11,7 @@ Creating tmux sessions with preconfigured panes layouts and commands. inspired f
#### Installation
```bash
go install github.com/xrehpicx/pee.git@latest
go install github.com/xrehpicx/pee@latest
```
#### Initialize a project

View File

@ -30,7 +30,6 @@ type Configuration struct {
LastOpened time.Time
Attach bool `yaml:"attach"`
StartupWindow string `yaml:"startup_window"`
StartupPane int `yaml:"startup_pane"`
}
var configDir string

View File

@ -26,8 +26,7 @@ func CreateTmuxSession(config *projectconfig.Configuration) error {
log.Debug("Ran command", "command", switchSessionCmd.String())
} else {
// If it doesn't exist, create the session
createSessionCmd := exec.Command("tmux", "new-session", "-d", "-s", sessionName, "-c", config.WorkingDir)
// createSessionCmd := exec.Command("tmux", "new-session", "-d", "-s", sessionName)
createSessionCmd := exec.Command("tmux", "new-session", "-d", "-s", sessionName)
if err := createSessionCmd.Run(); err != nil {
return err
}
@ -77,13 +76,6 @@ func CreateTmuxSession(config *projectconfig.Configuration) error {
}
log.Debug("Ran command", "command", selectPaneCmd.String())
// Change the working directory
changeDirCmd := exec.Command("tmux", "send-keys", "-t", paneName, "cd "+config.WorkingDir, "Enter")
if err := changeDirCmd.Run(); err != nil {
return err
}
log.Debug("Ran command", "command", changeDirCmd.String())
// Send commands to the pane
sendCommandsCmd := exec.Command("tmux", "send-keys", "-t", paneName, strings.Join(pane.ShellCommand, " && "), "Enter")
if err := sendCommandsCmd.Run(); err != nil {
@ -117,16 +109,6 @@ func CreateTmuxSession(config *projectconfig.Configuration) error {
}
log.Debug("Ran command", "command", selectWindowCmd.String())
// Select initial pane
if config.StartupPane > 0 {
defaultPane := fmt.Sprintf("%s:%d.%d", sessionName, config.StartupPane, 1)
selectPaneCmd := exec.Command("tmux", "select-pane", "-t", defaultPane)
if err := selectPaneCmd.Run(); err != nil {
return err
}
log.Debug("Ran command", "command", selectPaneCmd.String())
}
if config.Attach {
switchSessionCmd := exec.Command("tmux", "switch-client", "-t", sessionName)
if err := switchSessionCmd.Run(); err != nil {
@ -192,13 +174,6 @@ func createWindow(config *projectconfig.Configuration, sessionName string, index
}
log.Debug("Ran command", "command", selectPaneCmd.String())
// Change the working directory for the pane
changeDirCmd := exec.Command("tmux", "send-keys", "-t", paneName, "cd "+config.WorkingDir, "Enter")
if err := changeDirCmd.Run(); err != nil {
return err
}
log.Debug("Ran command", "command", changeDirCmd.String())
// Send commands to the pane
sendCommandsCmd := exec.Command("tmux", "send-keys", "-t", paneName, strings.Join(pane.ShellCommand, " && "), "Enter")
if err := sendCommandsCmd.Run(); err != nil {
@ -218,12 +193,3 @@ func createWindow(config *projectconfig.Configuration, sessionName string, index
return nil
}
func KillTmuxSession(sessionName string) error {
killSessionCmd := exec.Command("tmux", "kill-session", "-t", sessionName)
if err := killSessionCmd.Run(); err != nil {
return err
}
log.Debug("Ran command", "command", killSessionCmd.String())
return nil
}

View File

@ -16,24 +16,6 @@ var RootCmd = &cobra.Command{
},
}
var KillTmuxSessionCmd = &cobra.Command{
Use: "kill",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
sessionName := args[0]
err := controller.KillTmuxSession(sessionName)
if err != nil {
log.Error(err)
return
}
log.Debug("Killed tmux session", "name", sessionName)
},
}
func init() {
RootCmd.AddCommand(KillTmuxSessionCmd)
}
func ExecuteProjectEnv(projectName string) {
config, err := projectconfig.GetProjectConfig(projectName)
if err != nil {

View File

@ -92,19 +92,15 @@ func Table(columns []table.Column, rows []table.Row) (table.Row, string) {
)
s := table.DefaultStyles()
// rounded borders
s.Header = s.Header.
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240")).
BorderBottom(true).
Bold(false)
s.Selected = s.Selected.
Foreground(lipgloss.Color("229")).
Background(lipgloss.Color("240")).
Background(lipgloss.Color("57")).
Bold(false)
t.SetStyles(s)
m := model{t, "", help.New(), keys}