-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
kaks | ||
kks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
"syscall" | ||
) | ||
|
||
func Edit(filename, session, client string) { | ||
kakBinary, lookErr := exec.LookPath("kak") | ||
if lookErr != nil { | ||
panic(lookErr) | ||
if session != "" && client != "" { | ||
kakCommand := fmt.Sprintf("edit %s", filename) | ||
Send(kakCommand, session, client) | ||
os.Exit(0) | ||
} | ||
|
||
kakExecArgs := []string{"kak", "-s", session, filename} | ||
kakBinary, err := exec.LookPath("kak") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
kakExecArgs := []string{"kak"} | ||
|
||
sessions, err := exec.Command("kak", "-l").Output() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
if session != "" && strings.Contains(string(sessions), session) { | ||
kakExecArgs = append(kakExecArgs, "-c", session) | ||
} else if session != "" { | ||
// TODO: this gets killed if parent shell closes, use setsid? | ||
kakExecArgs = append(kakExecArgs, "-s", session) | ||
} | ||
|
||
kakExecArgs = append(kakExecArgs, filename) | ||
|
||
fmt.Print(kakExecArgs) | ||
|
||
execErr := syscall.Exec(kakBinary, kakExecArgs, os.Environ()) | ||
if execErr != nil { | ||
panic(execErr) | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module kaks | ||
module kks | ||
|
||
go 1.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ package main | |
import ( | ||
"flag" | ||
"fmt" | ||
"kaks/cmd" | ||
"kks/cmd" | ||
"os" | ||
"strings" | ||
) | ||
|