Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Sep 9, 2021
1 parent 49b09b5 commit a7b277e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@

- add kks send commands in kks-select script to indicate highlighted client
- add '-a' flag to kill cmd for killing all sessions

- https://www.digitalocean.com/community/tutorials/how-to-use-the-flag-package-in-go
4 changes: 2 additions & 2 deletions kak/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/fsnotify/fsnotify"
)

func Get(getStr, session, client string) ([]string, error) {
func Get(getStr, buf, session, client string) ([]string, error) {
// create a tmp file for kak to echo the value
f, err := os.CreateTemp("", "kks-tmp")
if err != nil {
Expand All @@ -23,7 +23,7 @@ func Get(getStr, session, client string) ([]string, error) {

// tell kak to echo the requested state
sendCmd := fmt.Sprintf("echo -quoting kakoune -to-file %s %%{ %s }", f.Name(), getStr)
if err := Send(sendCmd, "", session, client); err != nil {
if err := Send(sendCmd, buf, session, client); err != nil {
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions kak/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ func List() ([]KakSession, error) {
for _, session := range kakSessions {
s := KakSession{Name: session}

clients, err := Get("%val{client_list}", session, "")
clients, err := Get("%val{client_list}", "", session, "")
if err != nil {
return nil, err
}
s.Clients = clients

dir, err := Get("%sh{pwd}", session, "")
dir, err := Get("%sh{pwd}", "", session, "")
if err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions kks.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func main() {
sendBuffer := sendCmd.String("b", "", "send to specified buffer")
attachCmd := flag.NewFlagSet("attach", flag.ExitOnError)
getCmd := flag.NewFlagSet("get", flag.ExitOnError)
getBuffer := getCmd.String("b", "", "get from specified buffer")
killCmd := flag.NewFlagSet("kill", flag.ExitOnError)
envCmd := flag.NewFlagSet("env", flag.ExitOnError)
listCmd := flag.NewFlagSet("list", flag.ExitOnError)
Expand Down Expand Up @@ -152,7 +153,7 @@ func main() {
log.Fatal(err)
}

out, err := kak.Get(arg, context.session, context.client)
out, err := kak.Get(arg, *getBuffer, context.session, context.client)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -247,7 +248,7 @@ func main() {

buffer := *catBuffer
if buffer == "" {
buffile, err := kak.Get("%val{buffile}", context.session, context.client)
buffile, err := kak.Get("%val{buffile}", "", context.session, context.client)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -315,4 +316,6 @@ func printHelp() {
fmt.Println("ENVIRONMENT VARIABLES")
fmt.Println(" KKS_SESSION Kakoune session")
fmt.Println(" KKS_CLIENT Kakoune client")
fmt.Println()
fmt.Println("Use \"kks <command> -h\" for command usage.")
}

0 comments on commit a7b277e

Please sign in to comment.