diff options
| author | Paul Buetow <paul@buetow.org> | 2025-11-01 23:12:20 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-11-01 23:12:20 +0200 |
| commit | c87e2837112c064da8528d38727dd7cad7acaa32 (patch) | |
| tree | 51612e1a43e6f6f73ea168d74285b5dfc4b74a53 /completions | |
| parent | 28ccc70feeab8aef7bcafaea75e288e6e58c2034 (diff) | |
Add fish shell integration with dynamic command completion (v0.2.0)v0.2.0
Amp-Thread-ID: https://ampcode.com/threads/T-9aec59d6-cd27-4607-ac11-baac5f2ca758
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'completions')
| -rw-r--r-- | completions/ge.fish | 53 | ||||
| -rw-r--r-- | completions/geheim.fish | 33 |
2 files changed, 86 insertions, 0 deletions
diff --git a/completions/ge.fish b/completions/ge.fish new file mode 100644 index 0000000..8a1206a --- /dev/null +++ b/completions/ge.fish @@ -0,0 +1,53 @@ +# Fish wrapper and completion for ge (geheim shortcut) +# Install to ~/.config/fish/functions/ge.fish + +function ge --description 'Geheim wrapper with shortcuts' + # If no arguments, run interactive mode + if test (count $argv) -eq 0 + geheim shell + return $status + end + + set -l cmd $argv[1] + + # Check if first argument is a known command + if contains $cmd (geheim commands 2>/dev/null) + # It's a command, pass through to geheim + geheim $argv + else + # Not a command, treat as search term + geheim search $argv + end +end + +# Dynamically load commands from geheim +function __fish_ge_commands + geheim commands 2>/dev/null +end + +# Get list of entries for completion +function __fish_ge_entries + # Only run if PIN is set to avoid interactive prompt + if set -q PIN + geheim ls 2>/dev/null | string replace -r ';.*$' '' | string trim + end +end + +# Complete subcommands or search terms +complete -c ge -f -n "__fish_use_subcommand" -a "(__fish_ge_commands)" +complete -c ge -f -n "__fish_use_subcommand" -a "(__fish_ge_entries)" + +# Complete search terms for commands that need them +complete -c ge -f -n "__fish_seen_subcommand_from search cat paste export pathexport open edit rm" -a "(__fish_ge_entries)" + +# Complete file paths for import +complete -c ge -n "__fish_seen_subcommand_from import" -F + +# Complete directory paths for import destination +complete -c ge -n "__fish_seen_subcommand_from import; and __fish_is_nth_token 3" -F -a "(__fish_complete_directories)" + +# Force flag for import +complete -c ge -n "__fish_seen_subcommand_from import; and __fish_is_nth_token 4" -f -a "force" + +# Complete directory paths for import_r +complete -c ge -n "__fish_seen_subcommand_from import_r" -F -a "(__fish_complete_directories)" diff --git a/completions/geheim.fish b/completions/geheim.fish new file mode 100644 index 0000000..c36ad03 --- /dev/null +++ b/completions/geheim.fish @@ -0,0 +1,33 @@ +# Fish completion for geheim +# Install to ~/.config/fish/completions/geheim.fish + +# Dynamically load commands from geheim +function __fish_geheim_commands + geheim commands 2>/dev/null +end + +# Get list of entries for completion +function __fish_geheim_entries + # Only run if PIN is set to avoid interactive prompt + if set -q PIN + geheim ls 2>/dev/null | string replace -r ';.*$' '' | string trim + end +end + +# Complete subcommands +complete -c geheim -f -n "__fish_use_subcommand" -a "(__fish_geheim_commands)" + +# Complete search terms for commands that need them +complete -c geheim -f -n "__fish_seen_subcommand_from search cat paste export pathexport open edit rm" -a "(__fish_geheim_entries)" + +# Complete file paths for import +complete -c geheim -n "__fish_seen_subcommand_from import" -F + +# Complete directory paths for import destination +complete -c geheim -n "__fish_seen_subcommand_from import; and __fish_is_nth_token 3" -F -a "(__fish_complete_directories)" + +# Force flag for import +complete -c geheim -n "__fish_seen_subcommand_from import; and __fish_is_nth_token 4" -f -a "force" + +# Complete directory paths for import_r +complete -c geheim -n "__fish_seen_subcommand_from import_r" -F -a "(__fish_complete_directories)" |
