diff --git a/kittens/icat/main.go b/kittens/icat/main.go index 2ce81c278..c2f521e40 100644 --- a/kittens/icat/main.go +++ b/kittens/icat/main.go @@ -222,7 +222,7 @@ func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) { keep_going.Store(true) if !opts.DetectSupport && num_of_items > 0 { num_workers := utils.Max(1, utils.Min(num_of_items, runtime.NumCPU())) - for i := 0; i < num_workers; i++ { + for range num_workers { go run_worker() } } diff --git a/kittens/panel/main.go b/kittens/panel/main.go new file mode 100644 index 000000000..a6ff0372a --- /dev/null +++ b/kittens/panel/main.go @@ -0,0 +1,60 @@ +package panel + +import ( + "fmt" + "os" + "path/filepath" + "runtime" + "strings" + + "kitty/tools/cli" + "kitty/tools/utils" + + "golang.org/x/sys/unix" +) + +var _ = fmt.Print + +func complete_kitty_listen_on(completions *cli.Completions, word string, arg_num int) { + if !strings.Contains(word, ":") { + mg := completions.AddMatchGroup("Address family") + mg.NoTrailingSpace = true + for _, q := range []string{"unix:", "tcp:"} { + if strings.HasPrefix(q, word) { + mg.AddMatch(q) + } + } + } else if strings.HasPrefix(word, "unix:") && !strings.HasPrefix(word, "unix:@") { + cli.FnmatchCompleter("UNIX sockets", cli.CWD, "*")(completions, word[len("unix:"):], arg_num) + completions.AddPrefixToAllMatches("unix:") + } +} + +func GetQuickAccessKittyExe() (kitty_exe string, err error) { + if kitty_exe, err = filepath.EvalSymlinks(utils.KittyExe()); err != nil { + return "", fmt.Errorf("Failed to find path to the kitty executable, this kitten requires the kitty executable to function. The kitty executable or a symlink to it must be placed in the same directory as the kitten executable. Error: %w", err) + } + if runtime.GOOS == "darwin" { + q := filepath.Join(filepath.Dir(filepath.Dir(kitty_exe)), "kitty-quick-access.app", "Contents", "MacOS", "kitty-quick-access") + if err := unix.Access(q, unix.X_OK); err == nil { + kitty_exe = q + } + } + return kitty_exe, nil + +} + +func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) { + kitty_exe, err := GetQuickAccessKittyExe() + if err != nil { + return 1, err + } + argv := []string{kitty_exe, "+kitten", "panel"} + err = unix.Exec(kitty_exe, append(argv, args...), os.Environ()) + rc = 1 + return +} + +func EntryPoint(parent *cli.Command) { + create_cmd(parent, main) +} diff --git a/tools/cmd/tool/main.go b/tools/cmd/tool/main.go index aa608cd69..1643ee715 100644 --- a/tools/cmd/tool/main.go +++ b/tools/cmd/tool/main.go @@ -13,6 +13,7 @@ import ( "kitty/kittens/hyperlinked_grep" "kitty/kittens/icat" "kitty/kittens/notify" + "kitty/kittens/panel" "kitty/kittens/query_terminal" "kitty/kittens/show_key" "kitty/kittens/ssh" @@ -53,6 +54,8 @@ func KittyToolEntryPoints(root *cli.Command) { ssh.EntryPoint(root) // transfer transfer.EntryPoint(root) + // panel + panel.EntryPoint(root) // unicode_input unicode_input.EntryPoint(root) // show_key