mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 09:15:57 +02:00
Function to extract terminfo
This commit is contained in:
@@ -20,9 +20,9 @@ var _ = fmt.Print
|
||||
|
||||
type integration_setup_func = func(shell_integration_dir string, argv []string, env map[string]string) ([]string, map[string]string, error)
|
||||
|
||||
func extract_shell_integration_for(shell_name string, dest_dir string) (err error) {
|
||||
func extract_files(match, dest_dir string) (err error) {
|
||||
d := Data()
|
||||
for _, fname := range d.FilesMatching("shell-integration/" + shell_name + "/") {
|
||||
for _, fname := range d.FilesMatching(match) {
|
||||
entry := d[fname]
|
||||
dest := filepath.Join(dest_dir, fname)
|
||||
ddir := filepath.Dir(dest)
|
||||
@@ -50,6 +50,18 @@ func extract_shell_integration_for(shell_name string, dest_dir string) (err erro
|
||||
return
|
||||
}
|
||||
|
||||
func extract_shell_integration_for(shell_name string, dest_dir string) (err error) {
|
||||
return extract_files("shell-integration/"+shell_name+"/", dest_dir)
|
||||
}
|
||||
|
||||
func extract_terminfo(dest_dir string) (err error) {
|
||||
if err = extract_files("terminfo/", dest_dir); err == nil {
|
||||
dest := filepath.Join(dest_dir, "terminfo", "78")
|
||||
err = os.Symlink("x", dest)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func EnsureShellIntegrationFilesFor(shell_name string) (shell_integration_dir_for_shell string, err error) {
|
||||
if kid := os.Getenv("KITTY_INSTALLATION_DIR"); kid != "" {
|
||||
if s, e := os.Stat(kid); e == nil && s.IsDir() {
|
||||
|
||||
@@ -39,4 +39,11 @@ func TestExtractShellIntegration(t *testing.T) {
|
||||
if !bytes.Equal(changed, orig) {
|
||||
t.Fatalf("Failed to update shell integration file")
|
||||
}
|
||||
|
||||
if err = extract_terminfo(tdir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(tdir, "terminfo", "78", "xterm-kitty")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user