From 20555a91c9ad6b696e76ef882dab3bf412ca2ffb Mon Sep 17 00:00:00 2001
From: "Lockszmith (@VAST)" <gal.szkolnik@vastdata.com>
Date: Mon, 10 Mar 2025 16:24:24 -0400
Subject: [PATCH] Add pet snippet management

---
 _home.macos/.chezmoiexternal.yaml             | 12 ++++++
 .../private_dot_config/pet/config.toml        |  1 +
 .../private_dot_config/pet/snippet.toml       |  1 +
 .../private_dot_config/sz.env/zza_pet.env     |  1 +
 _src.posix/private_dot_config/pet/config.toml | 37 +++++++++++++++++++
 .../private_dot_config/pet/snippet.toml       | 18 +++++++++
 .../private_dot_config/sz.env/zza_pet.env     |  9 +++++
 7 files changed, 79 insertions(+)
 create mode 120000 _home.macos/private_dot_config/pet/config.toml
 create mode 120000 _home.macos/private_dot_config/pet/snippet.toml
 create mode 120000 _home.macos/private_dot_config/sz.env/zza_pet.env
 create mode 100644 _src.posix/private_dot_config/pet/config.toml
 create mode 100644 _src.posix/private_dot_config/pet/snippet.toml
 create mode 100644 _src.posix/private_dot_config/sz.env/zza_pet.env

diff --git a/_home.macos/.chezmoiexternal.yaml b/_home.macos/.chezmoiexternal.yaml
index 1d84c22..af73af5 100644
--- a/_home.macos/.chezmoiexternal.yaml
+++ b/_home.macos/.chezmoiexternal.yaml
@@ -56,6 +56,18 @@
 {{-   end -}}
 {{- end -}}
 
+{{- with $repo := "knqyf263/pet" -}}
+{{-   with $version := trimPrefix "v" (gitHubLatestRelease $repo).GetTagName -}}
+{{-     $_ := set $externals ".local/bin/pet" (dict
+          "type" "archive-file"
+          "url" (printf "https://github.com/%s/releases/download/v%s/pet_%s_%s.tar.gz" $repo $version $version $myArch)
+          "path" "pet"
+          "executable" true
+          "refreshPeriod" $defaultRefresh
+) -}}
+{{-   end -}}
+{{- end -}}
+
 {{ $myArch = "mac" }}
 
 {{- with $repo := "extrawurst/gitui" -}}
diff --git a/_home.macos/private_dot_config/pet/config.toml b/_home.macos/private_dot_config/pet/config.toml
new file mode 120000
index 0000000..434a914
--- /dev/null
+++ b/_home.macos/private_dot_config/pet/config.toml
@@ -0,0 +1 @@
+../../../_src.posix/private_dot_config/pet/config.toml
\ No newline at end of file
diff --git a/_home.macos/private_dot_config/pet/snippet.toml b/_home.macos/private_dot_config/pet/snippet.toml
new file mode 120000
index 0000000..47f0c4c
--- /dev/null
+++ b/_home.macos/private_dot_config/pet/snippet.toml
@@ -0,0 +1 @@
+../../../_src.posix/private_dot_config/pet/snippet.toml
\ No newline at end of file
diff --git a/_home.macos/private_dot_config/sz.env/zza_pet.env b/_home.macos/private_dot_config/sz.env/zza_pet.env
new file mode 120000
index 0000000..a35fff6
--- /dev/null
+++ b/_home.macos/private_dot_config/sz.env/zza_pet.env
@@ -0,0 +1 @@
+../../../_src.posix/private_dot_config/sz.env/zza_pet.env
\ No newline at end of file
diff --git a/_src.posix/private_dot_config/pet/config.toml b/_src.posix/private_dot_config/pet/config.toml
new file mode 100644
index 0000000..47fb719
--- /dev/null
+++ b/_src.posix/private_dot_config/pet/config.toml
@@ -0,0 +1,37 @@
+[General]
+  Backend = "gist" # specify backend service to sync snippets (gist, ghe or gitlab, default: gist)
+  cmd = ["sh", "-c"]              # specify the command to execute the snippet with
+  Color = false # enables output coloring with fzf, same as '--color' flag
+  Column = 40 # column size for list command
+  Editor = "vim" # your favorite text editor
+  Format = "[$description]: $command $tags" # controls the format of the output when searching
+  SelectCmd = "fzf --ansi --layout=reverse --border --height=90% --pointer=* --cycle --prompt=Snippets:" # selector command for edit command (fzf or peco)
+  SnippetDirs = []
+  SnippetFile = "/Users/gal.szkolnik/.config/pet/snippet.toml" # specify snippet path
+  SortBy = "" # specify how snippets get sorted (recency (default), -recency, description, -description, command, -command, output, -output)
+
+[Gist]
+  file_name = "pet-snippet.toml" 
+  access_token = ""               # your access token
+  gist_id = ""                    # Gist ID
+  Public = false                  # public or priate
+  auto_sync = false               # sync automatically when editing snippets
+
+[GitLab]
+  file_name = "pet-snippet.toml"  # specify GitLab Snippets file name
+  access_token = "XXXXXXXXXXXXX"  # your access token
+  ID = ""                         # GitLab Snippets ID
+  Visibility = "private"          # public or internal or private
+  auto_sync = false               # sync automatically when editing snippets
+
+  Url = ""
+  skip_ssl = false
+
+[GHEGist]
+  Public = false
+  access_token = ""
+  auto_sync = false
+  base_url = ""
+  file_name = ""
+  gist_id = ""
+  upload_url = ""
diff --git a/_src.posix/private_dot_config/pet/snippet.toml b/_src.posix/private_dot_config/pet/snippet.toml
new file mode 100644
index 0000000..cb4630e
--- /dev/null
+++ b/_src.posix/private_dot_config/pet/snippet.toml
@@ -0,0 +1,18 @@
+
+[[Snippets]]
+  Description = "shell's nil"
+  Output = ""
+  Tag = []
+  command = ": ;"
+
+[[Snippets]]
+  Description = "echo"
+  Output = ""
+  Tag = []
+  command = "echo"
+
+[[Snippets]]
+  Description = "Initialize MacBook Pro connection into TechPort"
+  Output = ""
+  Tag = []
+  command = "lsif\nlsip\npull-vast.id_rsa 0\nvastconnect 192.168.2.2\nauto-copy-ssh-id 192.168.2.2"
diff --git a/_src.posix/private_dot_config/sz.env/zza_pet.env b/_src.posix/private_dot_config/sz.env/zza_pet.env
new file mode 100644
index 0000000..30aeba1
--- /dev/null
+++ b/_src.posix/private_dot_config/sz.env/zza_pet.env
@@ -0,0 +1,9 @@
+#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"'
+
+BASE_SHELL=${BASE_SHELL:-${SHELL##*/}}
+
+if is_cmd pet; then
+    . <( pet completion ${BASE_SHELL} )
+
+    [[ -n "${DBG}" ]] && echo "pet loaded."
+fi