mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 17:52:02 +02:00
Start work on quick-access-terminal kitten
This commit is contained in:
@@ -30,6 +30,8 @@ func complete_kitty_listen_on(completions *cli.Completions, word string, arg_num
|
||||
}
|
||||
}
|
||||
|
||||
var CompleteKittyListenOn = complete_kitty_listen_on
|
||||
|
||||
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)
|
||||
|
||||
0
kittens/quick_access_terminal/__init__.py
Normal file
0
kittens/quick_access_terminal/__init__.py
Normal file
32
kittens/quick_access_terminal/main.go
Normal file
32
kittens/quick_access_terminal/main.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package quick_access_terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"kitty/kittens/panel"
|
||||
"kitty/tools/cli"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
var complete_kitty_listen_on = panel.CompleteKittyListenOn
|
||||
|
||||
func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
kitty_exe, err := panel.GetQuickAccessKittyExe()
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
argv := []string{kitty_exe, "+kitten", "panel"}
|
||||
argv = append(argv, o.AsCommandLine()...)
|
||||
argv = append(argv, args...)
|
||||
err = unix.Exec(kitty_exe, argv, os.Environ())
|
||||
rc = 1
|
||||
return
|
||||
}
|
||||
|
||||
func EntryPoint(parent *cli.Command) {
|
||||
create_cmd(parent, main)
|
||||
}
|
||||
43
kittens/quick_access_terminal/main.py
Normal file
43
kittens/quick_access_terminal/main.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import sys
|
||||
|
||||
from kitty.simple_cli_definitions import build_panel_cli_spec
|
||||
|
||||
help_text = 'A quick access terminal window that you can bring up instantly with a keypress or a command.'
|
||||
|
||||
|
||||
def options_spec() -> str:
|
||||
if not (ans := getattr(options_spec, 'ans', '')):
|
||||
ans = build_panel_cli_spec({
|
||||
'lines': '25',
|
||||
'columns': '80',
|
||||
'edge': 'top',
|
||||
'layer': 'overlay',
|
||||
'toggle_visibility': 'yes',
|
||||
'single_instance': 'yes',
|
||||
'instance_group': 'quake',
|
||||
'focus_policy': 'exclusive',
|
||||
'cls': 'kitty-quick-access',
|
||||
'exclusive_zone': '0',
|
||||
'override_exclusive_zone': 'yes',
|
||||
'override': 'background_opacity=0.8',
|
||||
})
|
||||
setattr(options_spec, 'ans', ans)
|
||||
return ans
|
||||
|
||||
|
||||
def main(args: list[str]) -> None:
|
||||
from ..panel.main import main as panel_main
|
||||
return panel_main(args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
||||
elif __name__ == '__doc__':
|
||||
cd: dict = sys.cli_docs # type: ignore
|
||||
cd['usage'] = '[cmdline-to-run ...]'
|
||||
cd['options'] = options_spec
|
||||
cd['help_text'] = help_text
|
||||
cd['short_desc'] = help_text
|
||||
@@ -112,7 +112,7 @@ func TestSSHConfigParsing(t *testing.T) {
|
||||
hostname = "2"
|
||||
rt()
|
||||
|
||||
ci, err := ParseCopyInstruction("--exclude moose --dest=target " + cf)
|
||||
ci, err := ParseCopyInstruction("--exclude moose --exclude second --dest=target " + cf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func TestSSHConfigParsing(t *testing.T) {
|
||||
if diff != "" {
|
||||
t.Fatalf("Incorrect local_path:\n%s", diff)
|
||||
}
|
||||
diff = cmp.Diff([]string{"moose"}, ci[0].exclude_patterns)
|
||||
diff = cmp.Diff([]string{"moose", "second"}, ci[0].exclude_patterns)
|
||||
if diff != "" {
|
||||
t.Fatalf("Incorrect excludes:\n%s", diff)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user