-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
3d9e682
commit 1665db3
Showing
4 changed files
with
82 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func main() { | ||
app := &cli.App{ | ||
Name: "goiterm", | ||
Commands: []*cli.Command{ | ||
{ | ||
Name: "install", | ||
Usage: "goiterm install <go binary name>", | ||
Description: "Installs your plugin to the iTerm app", | ||
Action: func(c *cli.Context) error { | ||
bin := c.Args().First() | ||
if bin == "" { | ||
return cli.NewExitError("must pass go binary as first argument", 1) | ||
} | ||
homedir, err := os.UserHomeDir() | ||
if err != nil { | ||
return fmt.Errorf("os.UserHomeDir: %w", err) | ||
} | ||
p := filepath.Join(homedir, "/Library/Application Support/iTerm2/Scripts/", bin+".py") | ||
f := fmt.Sprintf(pyFile, bin) | ||
err = ioutil.WriteFile(p, []byte(f), 0666) | ||
if err != nil { | ||
return fmt.Errorf("ioutil.WriteFile: %w", err) | ||
} | ||
return nil | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
err := app.Run(os.Args) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
const pyFile = `#!/usr/bin/env python3.7 | ||
import subprocess | ||
subprocess.run(["%s"]) | ||
` |
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
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