fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
a9618477e
master
1function __fish_exif_target_file_tags 2for targetin ( string match -v --'-*' ( commandline -px)[ 2..]) 3string replace -f'*' '' ( exif --list-tags" $target " 2> /dev/null)[ 2..] | string replace -r'(\s+-){4}' '' | string split -m1' ' | string trim 4end 5end 6 7function __fish_exif_potential_targets 8set -l token( commandline -t) 9set -l matching_files( complete -C"__fish_command_without_completions $token " ) 10for filein $matching_files 11if test -d " $file " 12echo $file 13else if exif " $file " &> /dev/null 14echo $file 15else if not test -e " $file " 16# Handle filenames containing $. 17if exif $file &> /dev/null 18echo $file 19end 20end 21end 22end 23 24function __fish_exif_token_begins_with_arg 25not string match --'-*' ( commandline -t) 26end 27 28complete -c exif -f -a"(__fish_exif_potential_targets)" -n __fish_exif_token_begins_with_arg 29 30for linein ( exif --help) 31set -l short 32set -l long 33set -l description 34if set -l matches( string match -r'^\s+-([\w?]),\s--([\w=-]+)\s+(.*)$' " $line " ) 35set short$matches [ 2 ] 36set long$matches [ 3 ] 37set description$matches [ 4 ] 38else if set -l matches( string match -r'^\s+--([\w=-]+)\s+(.*)$' " $line " ) 39set long$matches [ 2 ] 40set description$matches [ 3 ] 41else 42continue 43end 44 45if set -l sub_parts( string split -n --max1 '=' $long ) 46set long" $sub_parts [ 1 ] " 47switch ( string lower" $sub_parts [ 2 ] " ) 48case tag 49complete -c exif -s$short -l$long -d" $description " -x -a"(__fish_exif_target_file_tags)" 50case ifd 51complete -c exif -s$short -l$long -d" $description " -x -a"0 1 EXIF GPS Interoperability" 52case file 53complete -c exif -s$short -l$long -d" $description " -F 54case "*" 55complete -c exif -s$short -l$long -d" $description " -x 56end 57else 58complete -c exif -s$short -l$long -d" $description " 59end 60end