fork/fish-shell

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

Fabian BoehmYet more shortening00e0d6ad9

master
7.0 KiB193 linesraw
1function __reg_run_reg_safely
2    set -l output (reg $argv | tr -d '\r' | tail --lines +2 | string collect)
3    if not string match -q -r "reg: Invalid syntax*" -- $output
4        set output (string split \n -- $output)
5        echo $output | string replace -a " " \n
6    end
7end
8
9function __reg_add_complete_args -a previous_token
10    if test "$previous_token" = add
11        set -l current_token (commandline -tc)
12        __reg_run_reg_safely query $current_token
13        return
14    end
15
16    if test "$previous_token" = /t
17        echo 'REG_SZ
18REG_MULTI_SZ
19REG_DWORD_BIG_ENDIAN
20REG_DWORD
21REG_BINARY
22REG_DWORD_LITTLE_ENDIAN
23REG_LINK
24REG_FULL_RESOURCE_DESCRIPTOR
25REG_EXPAND_SZ'
26        return
27    end
28
29    if not __fish_seen_argument -w v -w ve
30        echo -e '/v\tSpecify the name of the add registry entry
31/ve\tSpecify that the added registry entry has a null value'
32    end
33
34    echo -e '/t\tSpecify the type for the registry entry
35/s\tSpecify the character to be used
36/d\tSpecify the data for the new registry entry
37/f\tAdd the registry entry without prompting for confirmation
38/?\tShow help'
39end
40
41function __reg_compare_complete_args
42    if not __fish_seen_argument -w v -w ve
43        echo -e '/v\tSpecify the value name
44/ve\tSpecify that only entries that have a value name of null should be compared'
45    end
46
47    if not __fish_seen_argument -w oa -w od -w os -w on
48        echo -e '/oa\tSpecify that all differences and matches are displayed
49/od\tSpecify that only differences are displayed
50/os\tSpecify that only matches are displayed
51/on\tSpecify that nothing is displayed'
52    end
53
54    echo -e '/s\tCompare all subkeys and entries recursively
55/?\tShow help'
56end
57
58function __reg_copy_complete_args
59    echo -e '/s\tCopy all subkeys and entries under the specified subkey
60/f\tCopy the subkey without prompting for confirmation
61/?\tShow help'
62end
63
64function __reg_delete_complete_args -a previous_token
65    if test "$previous_token" = delete
66        set -l current_token (commandline -tc)
67        __reg_run_reg_safely query $current_token
68        return
69    end
70
71    if not __fish_seen_argument -w v -w ve -w va
72        echo -e '/v\tDelete a specific entry under the subkey
73/ve\tSpecify that only entries that have no value will be deleted
74/va\tDelete all entries under the specified subkey'
75    end
76
77    echo -e '/f\tDelete the existing registry subkey or entry without asking for confirmation
78/?\tShow help'
79end
80
81function __reg_export_complete_args -a previous_token
82    if test "$previous_token" = export
83        set -l current_token (commandline -tc)
84        __reg_run_reg_safely query $current_token
85        return
86    end
87
88    echo -e '/y\tOverwrite any existing file with the name filename without prompting for confirmation
89/?\tShow help'
90end
91
92function __reg_query_complete_args -a previous_token
93    if test "$previous_token" = query
94        set -l current_token (commandline -tc)
95        __reg_run_reg_safely query $current_token
96        return
97    end
98
99    if test "$previous_token" = /t
100        echo 'REG_SZ
101REG_MULTI_SZ
102REG_EXPAND_SZ
103REG_DWORD
104REG_BINARY
105REG_NONE'
106        return
107    end
108
109    if not __fish_seen_argument -w v -w ve
110        echo -e '/v\tSpecify the registry value name
111/ve\tRun a query for value names that are empty'
112    end
113
114    if not __fish_seen_argument -w k -w d
115        echo -e '/k\tSpecify to search in key names only
116/d\tSpecify to search in data only'
117    end
118
119    echo -e '/se\tSpecify the single value separator
120/f\tSpecify the data or pattern to search for
121/c\tSpecify that the query is case sensitive
122/e\tSpecify to return only exact matches
123/t\tSpecify registry types to search
124/z\tSpecify to include the numeric equivalent for the registry type in search results
125/?\tShow help'
126end
127
128function __reg_save_complete_args -a previous_token
129    if test "$previous_token" = save
130        set -l current_token (commandline -tc)
131        __reg_run_reg_safely query $current_token
132        return
133    end
134
135    echo -e '/y\tOverwrite an existing file with the name filename without prompting for confirmation
136/?\tShow help'
137end
138
139function __reg_complete_args -d 'Function to generate args'
140    set -l previous_token (commandline -xc)[-1]
141
142    if __fish_seen_subcommand_from add
143        __reg_add_complete_args $previous_token
144    else if __fish_seen_subcommand_from compare
145        __reg_compare_complete_args
146    else if __fish_seen_subcommand_from copy
147        __reg_copy_complete_args
148    else if __fish_seen_subcommand_from delete
149        __reg_delete_complete_args $previous_token
150    else if __fish_seen_subcommand_from export
151        __reg_export_complete_args $previous_token
152    else if __fish_seen_subcommand_from query
153        __reg_query_complete_args $previous_token
154    else if __fish_seen_subcommand_from save
155        __reg_save_complete_args $previous_token
156    end
157end
158
159complete -c reg -f -a '(__reg_complete_args)'
160
161complete -c reg -f \
162    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a add \
163    -d 'Add a new subkey or entry'
164complete -c reg -f \
165    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a compare \
166    -d 'Compare specified registry subkeys or entries'
167complete -c reg -f \
168    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a copy \
169    -d 'Copy a registry entry'
170complete -c reg -f \
171    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a delete \
172    -d 'Delete a subkey or entries'
173complete -c reg -f \
174    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a export \
175    -d 'Copy the specified subkeys, entries, and values of the local computer into a file'
176complete -c reg -f \
177    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a import \
178    -d 'Copy contents of a file with registry data into the local registry'
179complete -c reg -f \
180    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a load \
181    -d 'Write saved subkeys and entries into a different subkey in the registry'
182complete -c reg -f \
183    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a query \
184    -d 'Return a list of the next tier of subkeys and entries'
185complete -c reg -f \
186    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a restore \
187    -d 'Write saved subkeys and entries back'
188complete -c reg -f \
189    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a save \
190    -d 'Save a copy of specified subkeys, entries, and values of the registry in a specified file'
191complete -c reg -f \
192    -n 'not __fish_seen_subcommand_from add compare copy delete export import load query restore save unload' -a unload \
193    -d 'Remove a section of the registry that was loaded using the reg load operation'