blob: 8a1206a5963fd28213bfaef8748372592f20f6cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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)"
|