home-config/fish/functions/_tide_remove_unusable_items.fish

01132663060e0ace2badde34ba25a216b22db15d · 1.1 KB · 25 lines raw

1 function _tide_remove_unusable_items
2 # Remove tool-specific items for tools the machine doesn't have installed
3 set -l removed_items
4 for item in aws crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc terraform toolbox zig
5 contains $item $tide_left_prompt_items $tide_right_prompt_items || continue
6
7 set -l cli_names $item
8 switch $item
9 case distrobox # there is no 'distrobox' command inside the container
10 set cli_names distrobox-export # 'distrobox-export' and 'distrobox-host-exec' are available
11 case nix_shell
12 set cli_names nix nix-shell
13 case python
14 set cli_names python python3
15 end
16 type --query $cli_names || set -a removed_items $item
17 end
18
19 set -U _tide_left_items (for item in $tide_left_prompt_items
20 contains $item $removed_items || echo $item
21 end)
22 set -U _tide_right_items (for item in $tide_right_prompt_items
23 contains $item $removed_items || echo $item
24 end)
25 end