fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
78c948282
master
1# Fish completions for gnome's "dconf" configuration tool 2 3function __fish_dconf_keys 4set -l dir 5set -l key 6# We parse the `dump` output instead of `list` 7# because it allows us to complete non-incrementally 8# i.e. to get the keys directly, without going through 9# `dconf list /`, `dconf list /org/` and so on. 10dconf dump /2> /dev/null| while read -l line 11if string match -q"[*]" --$line 12# New directory - just save it for the keys 13set dir /( string trim -c"[]" --$line ) 14else if test -n " $line " 15# New key - output with the dir prepended. 16echo $dir /( string replace -r'=.*' '' --$line ) 17end 18end 19end 20 21### Commands 22set -l commands read list write reset compile update watch dump load help 23 24complete -f -c dconf 25complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a read -d'Read the value of a key' 26complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a list -d'List the sub-keys and sub-directories of a directory' 27complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a write -d'Write a new value to a key' 28complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a reset -d'Delete a key or an entire directory' 29complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a compile -d'Compile a binary database from keyfiles' 30complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a update -d'Update the system dconf databases' 31complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a watch -d'Watch a key or directory for changes' 32complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a dump -d'Dump an entire subpath to stdout' 33complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a load -d'Populate a subpath from stdin' 34complete -f -c dconf -n"not __fish_seen_subcommand_from $commands " -a help -d'Display help and exit' 35 36### Arguments to commands 37# Technically, reset/watch take a "PATH" (which is a dir or a key) 38# while read and write take a KEY, but for now this is close enough. 39complete -f -c dconf -n"__fish_seen_subcommand_from read write reset watch" -a"(__fish_dconf_keys)" 40# List/dump/load take a dir, which is something that ends in a "/" 41complete -f -c dconf -n"__fish_seen_subcommand_from list dump load" -a"(__fish_dconf_keys | string replace -r '/[^/]*\$' '/')" 42 43complete -f -c dconf -n"__fish_seen_subcommand_from help" -a" $commands "