Skip to content

Commit

Permalink
start work on functionality that checks if tmux exists. if it does, a…
Browse files Browse the repository at this point in the history
…ttach to it. if not, start a new session.
  • Loading branch information
giuseppe-g-gelardi committed Nov 22, 2023
1 parent 7df1b4f commit 4a9ec9c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ dist/
.env.*
!.env.example

# log file for local development
main.go
2 changes: 0 additions & 2 deletions cli/repo_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ func setRepoUrl(repo p.PartialRepo) string {

}

func bareRepo() {}

func RepoSelection(config *c.Config) {
s := spinner.New(spinner.CharSets[14], 100*time.Millisecond) // Build our new spinner])
s.Start() // Start the spinner
Expand Down
4 changes: 4 additions & 0 deletions session_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
access_token: ""
editor: vscode
alias: ""
tmux: false
14 changes: 14 additions & 0 deletions util/run_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func StartTmuxSession(sessionName string, editorCmd string) error {
editorCmd = editorCmd + " ."
session := StrFormat(sessionName)

/*
Check if tmux is already running
if it is, attach to the session
if not, start a new session
*/

// Start the tmux session
tmuxCmd := exec.Command("tmux", "new", "-s", string(session))
tmuxCmd.Stdout = os.Stdout
Expand Down Expand Up @@ -59,3 +65,11 @@ func StartTmuxSession(sessionName string, editorCmd string) error {
return nil
}

func IsTmuxActive() (bool, error) {
cmd := exec.Command("tmux", "info")
cmd.Stderr = cmd.Stdout

err := cmd.Run()

return err == nil, nil
}

0 comments on commit 4a9ec9c

Please sign in to comment.