File: __fish_print_gpg_algo.fish

package info (click to toggle)
fish 3.1.2-3%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 38,672 kB
  • sloc: ansic: 80,259; cpp: 47,069; javascript: 17,087; sh: 6,163; python: 3,429; makefile: 669; perl: 367; objc: 78; xml: 18
file content (30 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download | duplicates (3)
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
# Helper function for contextual autocompletion of GPG crypto algorithm options

function __fish_print_gpg_algo -d "Complete using all algorithms of the type specified in argv[2] supported by gpg. argv[2] is a regexp" -a __fish_complete_gpg_command
    # Set a known locale, so that the output format of 'gpg --version'
    # is at least somewhat predictable. The locale will automatically
    # expire when the function goes out of scope, and the original locale
    # will take effect again.
    set -lx LC_ALL C

    # sed script explained:
    # in the line that matches "$argv:"
    # 	define label 'loop'
    # 	if the line ends with a ','
    # 		add next line to buffer
    #		transliterate '\n' with ' '
    #		goto loop
    # 	remove everything until the first ':' of the line
    # 	remove all blanks
    # 	transliterate ',' with '\n' (OSX apparently doesn't like '\n' on RHS of the s-command)
    # 	print result
    $__fish_complete_gpg_command --version | sed -ne "/$argv[2]:/"'{:loop
    /,$/{N; y!\n! !
    b loop
    }
    s!^[^:]*:!!
    s![ ]*!!g
    y!,!\n!
    p
    }'
end