diff options
Diffstat (limited to 'home-config/fish/functions/_tide_item_pulumi.fish')
-rw-r--r-- | home-config/fish/functions/_tide_item_pulumi.fish | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/home-config/fish/functions/_tide_item_pulumi.fish b/home-config/fish/functions/_tide_item_pulumi.fish new file mode 100644 index 0000000..6302a7e --- /dev/null +++ b/home-config/fish/functions/_tide_item_pulumi.fish | |||
@@ -0,0 +1,19 @@ | |||
1 | function _tide_item_pulumi | ||
2 | if path filter $_tide_parent_dirs/Pulumi.yaml | read -l yaml_path | ||
3 | if command -q sha1sum | ||
4 | echo -n "$yaml_path" | sha1sum | string match -qr "(?<path_hash>.{40})" | ||
5 | else if command -q shasum | ||
6 | echo -n "$yaml_path" | shasum | string match -qr "(?<path_hash>.{40})" | ||
7 | else | ||
8 | return | ||
9 | end | ||
10 | |||
11 | string match -qr 'name: *(?<project_name>.*)' <$yaml_path | ||
12 | set -l workspace_file "$HOME/.pulumi/workspaces/$project_name-$path_hash-workspace.json" | ||
13 | |||
14 | if test -e $workspace_file | ||
15 | string match -qr '"stack": *"(?<stack>.*)"' <$workspace_file | ||
16 | _tide_print_item pulumi $tide_pulumi_icon' ' $stack | ||
17 | end | ||
18 | end | ||
19 | end | ||