fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes Altmanningercompletions/dd: re-use built-in file completion for "dd if=the-file"73b13315d

master
4.8 KiB74 linesraw
1complete -c dd -xa '(__fish_complete_dd)'
2complete -c dd -d 'display help and exit' -xa --help
3complete -c dd -d 'output version information and exit' -xa --version
4
5function __fish_complete_dd -d 'Complete dd operands'
6    # set operand_string as a local variable containing the current command-line token.
7    set -l operand_string (commandline -t)
8
9    switch $operand_string
10        case 'if=*' 'of=*'
11            string replace = ' ' -- $operand_string | read -l operand value
12
13            # Use normal file completions.
14            printf "$operand=%s\n" (complete -C "__fish_command_without_completions $value")
15
16        case 'iflag=*' 'oflag=*'
17            string replace = ' ' -- $operand_string | read -l operand complete
18            string match -q '*,' -- $complete
19            or set complete ''
20
21            printf "%s\t%s\n" "$operand=$complete""append" "append mode (makes sense only for output; conv=notrunc suggested)"
22            printf "%s\t%s\n" "$operand=$complete""direct" "use direct I/O for data"
23            printf "%s\t%s\n" "$operand=$complete""directory" "fail unless a directory"
24            printf "%s\t%s\n" "$operand=$complete""dsync" "use synchronized I/O for data"
25            printf "%s\t%s\n" "$operand=$complete""sync" "use synchronized I/O for data and metadata"
26            printf "%s\t%s\n" "$operand=$complete""fullblock" "accumulate full blocks of input (iflag only)"
27            printf "%s\t%s\n" "$operand=$complete""nonblock" "use non-blocking I/O"
28            printf "%s\t%s\n" "$operand=$complete""noatime" "do not update access time"
29            printf "%s\t%s\n" "$operand=$complete""nocache" "discard cached data"
30            printf "%s\t%s\n" "$operand=$complete""noctty" "do not assign controlling terminal from file"
31            printf "%s\t%s\n" "$operand=$complete""nofollow" "do not follow symbolic links"
32
33        case 'conv=*'
34            string replace = ' ' -- $operand_string | read -l operand complete
35            string match -q '*,' -- $complete
36            or set complete ''
37
38            printf "%s\t%s\n" "$operand=$complete""ascii" "from EBCDIC to ASCII"
39            printf "%s\t%s\n" "$operand=$complete""ebcdic" "from ASCII to EBCDIC"
40            printf "%s\t%s\n" "$operand=$complete""ibm" "from ASCII to alternate EBCDIC"
41            printf "%s\t%s\n" "$operand=$complete""block" "pad newline-terminated records with spaces to cbs-size"
42            printf "%s\t%s\n" "$operand=$complete""unblock" "replace trailing spaces in cbs-size records with newline"
43            printf "%s\t%s\n" "$operand=$complete""lcase" "change upper case to lower case"
44            printf "%s\t%s\n" "$operand=$complete""ucase" "change lower case to upper case"
45            printf "%s\t%s\n" "$operand=$complete""swab" "swap every pair of input bytes"
46            printf "%s\t%s\n" "$operand=$complete""sync" "pad every input block with NULs to ibs-size; with block or ublock use spaces"
47            printf "%s\t%s\n" "$operand=$complete""excl" "fail if the output file already exists"
48            printf "%s\t%s\n" "$operand=$complete""nocreat" "do not create the output file"
49            printf "%s\t%s\n" "$operand=$complete""notrunc" "do not truncate the output file"
50            printf "%s\t%s\n" "$operand=$complete""noerror" "continue after read errors"
51            printf "%s\t%s\n" "$operand=$complete""fdatasync" "physically write output file data before finishing"
52            printf "%s\t%s\n" "$operand=$complete""fsync" "physically write output file data and metadata before finishing"
53
54        case 'status=*'
55            printf "%s\t%s\n" status=noxfer "suppress final transfer statistics"
56            printf "%s\t%s\n" status=none "suppress everything but errors"
57            printf "%s\t%s\n" status=progress "show periodic transfer statistics"
58
59        case '*'
60            printf "%s=\t%s\n" bs "read and write up to BYTES bytes at a time"
61            printf "%s=\t%s\n" cbs "convert BYTES bytes at a time"
62            printf "%s=\t%s\n" conv "convert the file as per the comma separated symbol list"
63            printf "%s=\t%s\n" count "copy only BLOCKS input blocks"
64            printf "%s=\t%s\n" ibs "read up to BYTES bytes at a time (default 512)"
65            printf "%s=\t%s\n" if "read from FILE instead of stdin"
66            printf "%s=\t%s\n" iflag "read as per the comma separated symbol list"
67            printf "%s=\t%s\n" obs "write BYTES bytes at a time (default 512)"
68            printf "%s=\t%s\n" of "write to FILE instead of stdout"
69            printf "%s=\t%s\n" oflag "write as per the comma separated symbol list"
70            printf "%s=\t%s\n" seek "skip BLOCKS obs-sized blocks at the start of output"
71            printf "%s=\t%s\n" skip "skip BLOCKS ibs-sized blocks at the start of input"
72            printf "%s=\t%s\n" status "set the level of information to print to stderr"
73    end
74end