Debian Codegraph @

docs/man/git-lfs-completion.adoc

raw
1 = git-lfs-completion(1)
2
3 == NAME
4
5 git-lfs-completion - Shell tab-completion script generation for Git LFS
6
7 == SYNOPSIS
8
9 [source,role=synopsis,subs="verbatim,quotes"]
10 ----
11 *git lfs completion bash*
12 *git lfs completion fish*
13 *git lfs completion zsh*
14 ----
15
16 == DESCRIPTION
17
18 Outputs a script which, when executed in a session of the given shell,
19 will implement command-line tab-completion of Git LFS commands.
20
21 Each shell requires a different set of commands to load the completion
22 script, either for an individual session or automatically whenever a
23 new session is started. See the <<_examples>> section for details.
24
25 The script for each shell provides tab-completion of Git LFS command
26 names and flags, but does not offer completion of Git terms such as
27 the names of Git remotes, branches, or tags. (This may change in a
28 future release of Git LFS.)
29
30 By default, each shell's script supports Git LFS command completion
31 when prompted with a tab character entered following the program name
32 `git-lfs`. For instance, `git-lfs [Tab]` will list the available Git LFS
33 commands such as `fetch`, `migrate`, and `pull`, and `git-lfs pull --[Tab]`
34 will list the possible flags for the git-lfs-pull(1) command.
35
36 However, most users will be accustomed to using Git LFS as a program
37 invoked by Git, e.g., `git lfs checkout` or `git lfs pull`. To enable
38 tab-completion of Git LFS commands in this case, tab-completion for
39 regular Git commands must be active as well. Assuming this is true,
40 the scripts generated by the `git lfs completion` command should support
41 completion of Git LFS commands when a tab character is entered following
42 `git lfs`, such as `git lfs [Tab]` to list all available Git LFS commands
43 or `git lfs pull --[Tab]` to list that command's possible flags. See
44 the <<_shells>> section for details regarding Git tab-completion in
45 the supported shells.
46
47 As is common for shell tab-completion, a space must be entered after
48 the `git-lfs` or `git lfs` command names before the tab character will
49 cause the Git LFS completion script to be executed. Without the
50 space character, any active shell tab-completion will instead search for
51 programs whose names have a matching prefix.
52
53 The completion scripts make use of "hidden" Git LFS commands to request
54 completion results from the Git LFS client, specifically the
55 `git lfs \__complete` and `git lfs __completeNoDesc` commands. These
56 commands may be removed in the future, or their action may be altered
57 without notice, and so users should not call them directly or consider
58 them to be part of the officially documented Git LFS command-line
59 interface.
60
61 == SHELLS
62
63 The `git lfs completion` command supports three Unix shells, GNU Bash
64 (Bourne Again SHell), fish, and Zsh (Z shell). Tab-completion is
65 configured differently in each, both in general and specifically
66 for Git and therefore also for Git LFS.
67
68 On Windows, users who have Git LFS installed as part of the Git for Windows
69 project have access to an emulation of the Bash shell which is packaged
70 with Git for Windows.
71
72 * Bash:
73 +
74 While Bash does not offer tab-completion for Git by default, a completion
75 script is available from the Git project, as described in the documentation:
76 +
77 https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash
78 +
79 The script returned by the `git lfs completion bash` command should
80 be compatible with this Git completion script and allow for tab-completion
81 of Git LFS commands entered using either the `git lfs` or `git-lfs`
82 command formats.
83 +
84 After retrieving a copy of the Git completion script appropriate to your
85 version of Git, run the following command to load the script in your
86 current session:
87 +
88 ....
89 $ source git-completion.bash
90 ....
91 +
92 To load the script in all future sessions, add this command to your Bash
93 startup files, or place the file in one of the locations searched by
94 the utilities from the bash-completion package.
95 +
96 The bash-completion project, which is separate from the GNU Bash shell
97 itself, includes a large number of command completion scripts and utilities
98 to load them automatically when starting a new session:
99 +
100 https://github.com/scop/bash-completion
101 +
102 The Git LFS completion script for Bash depends on several functions provided
103 by the bash-completion package, and so that package must be installed in
104 order to use tab-completion with Git LFS commands. (It is not required
105 by the Git completion script for Bash, however.)
106 +
107 Assuming the bash-completion package is installed, to load the Git
108 completion script in all future sessions started by the current user
109 (but not all users), place the `git-completion.bash` script in the
110 `bash-completion/completions` directory within the location defined
111 by the `XDG_DATA_HOME` environment variable, or, if that variable is
112 not defined, the `~/.local/share` directory. For example:
113 +
114 ....
115 $ cp git-completion.bash ~/.local/share/bash-completion/completions/git
116 ....
117 +
118 For the bash-completion utilities to load the Git completion script for
119 all users, place the Git completion script in the appropriate system
120 directory. On Linux this may be `/usr/share/bash-completion/completions`,
121 and on macOS, when bash-completion is installed using Homebrew, it may
122 be the `share/bash-completion/completions` directory within the location
123 returned by the `brew --prefix` command. However, these locations will
124 vary depending on how the bash-completion package was installed.
125
126 * fish:
127 +
128 The fish shell provides its own implementation of Git command
129 tab-completion, defined in a `git.fish` file which is likely present
130 by default in the list of locations the shell searches for completion
131 scripts.
132 +
133 The script returned by the `git lfs completion fish` command should
134 be compatible with this implementation and allow for tab-completion
135 of Git LFS commands entered using either the `git lfs` or `git-lfs`
136 command formats.
137
138 * Zsh:
139 +
140 To enable tab-completion in Zsh for any commands, the `compinit` function
141 must be loaded first with a command similar to the following:
142 +
143 ....
144 % autoload -Uz compinit && compinit
145 ....
146 +
147 This may be done individually for each session, or added to a startup
148 file such as `~/.zshrc` or `/etc/zshrc` so it will apply to all future
149 sessions, either for the current user or for all users.
150 +
151 Zsh reads completion functions from the locations specified in the `FPATH`
152 environment variable, with the paths listed first taking precedence.
153 This list is also available as an array in the `fpath` variable; the
154 shell automatically synchronizes `FPATH` and `fpath`.
155 +
156 The Z shell provides its own implementation of Git command
157 tab-completion, defined in a `_git` file which is likely present in
158 one of the locations specified in `fpath`.
159 +
160 The script returned by the `git lfs completion zsh` command should
161 be compatible with this implementation and allow for tab-completion
162 of Git LFS commands entered using either the `git lfs` or `git-lfs`
163 command formats.
164 +
165 The Git project also offers completion scripts for Zsh, in the form of
166 the same `git-completion.bash` script used for the Bash shell, plus a
167 `git-completion.zsh` script which is intended to be renamed to `_git`
168 and placed in a location listed in `fpath`. These scripts are not
169 compatible with the one returned by the `git lfs completion zsh` command,
170 and if they used in conjunction with that script, tab-completion of
171 Git LFS commands will not function properly when initiated using the
172 `git lfs` command format.
173 +
174 On macOS, if Git is installed using Homebrew, the Git project's Zsh
175 completion scripts may be installed in a location where they take
176 precedence over the implementation provided by Zsh. In this case, to
177 make full use of the script returned by `git lfs completion zsh`, the
178 `_git` completion script file installed by Homebrew for Git must be moved
179 or removed so it does not precede the Z shell's own Git completion script
180 in the path order specified by `fpath`.
181
182 == EXAMPLES
183
184 === Loading completions for the current shell session
185
186 To load Git LFS command completions for the current shell session only,
187 execute the script generated by `git lfs completion` directly.
188
189 * Bash:
190 +
191 ....
192 $ source <(git lfs completion bash)
193 ....
194 +
195 Note that with Bash 3.2, the `source` builtin command will not properly
196 execute the output of a process substitution, and so it will be
197 necessary to use a temporary file instead:
198 +
199 ....
200 $ git lfs completion bash >git-lfs-completion.bash
201 $ source git-lfs-completion.bash
202 ....
203
204 * fish:
205 +
206 ....
207 > git lfs completion fish | source
208 ....
209
210 * zsh:
211 +
212 Note that the `compinit` function must also be executed to enable
213 tab-completion, as described in the <<_shells>> section.
214 +
215 ....
216 % source <(git lfs completion zsh)
217 ....
218
219 === Automatically loading completions for future shell sessions
220
221 To load Git LFS command completions in all future shell sessions,
222 store the script generated by `git lfs completion` in a location where
223 it will be read by your shell during session startup.
224
225 * Bash:
226 +
227 As mentioned in the <<_shells>> section, the bash-completion package
228 is required by the Git LFS completion scripts for Bash, and it also
229 provides convenient utilities which search for completion scripts in
230 a set of defined locations and execute them during session startup.
231 +
232 To load the Git LFS completion script in all future sessions started
233 by the current user (but not other users), store the script in the
234 `bash-completion/completions` directory within the location defined by
235 the `XDG_DATA_HOME` environment variable, or, if that variable is not
236 defined, the `~/.local/share` directory. For example:
237 +
238 ....
239 $ mkdir -p ~/.local/share/bash-completion/completions
240 $ git lfs completion bash >~/.local/share/bash-completion/completions/git-lfs
241 ....
242 +
243 To load the completion script in all users' future sessions, store the
244 script instead in an appropriate system directory, which on Linux may be
245 `/usr/share/bash-completion/completions`, or on macOS, if bash-completion
246 was installed using Homebrew, may be the `share/bash-completion/completions`
247 directory within the location returned by the `brew --prefix` command.
248 These locations will vary depending on how the bash-completion package
249 was installed and configured, however. For details, check the documentation
250 relevant to your system's bash-completion package.
251
252 * fish:
253 +
254 The fish shell searches for completion scripts in a number of locations,
255 as described in the documentation:
256 +
257 https://fishshell.com/docs/current/completions.html#where-to-put-completions
258 +
259 To load the Git LFS completion script in all sessions started by the
260 current user (but not other users), store the script in the
261 `fish/completions` directory within the location defined by the
262 `XDG_CONFIG_HOME` environment variable, or, if that variable is not
263 defined, the `~/.config` directory. For example:
264 +
265 ....
266 > mkdir -p ~/.config/fish/completions
267 > git lfs completion fish >~/.config/fish/completions/git-lfs.fish
268 ....
269 +
270 To load the completion script in all users' future sessions, store the
271 script in one of the other locations searched by the shell, such under
272 `fish/completions` within the shell's system configuration directory.
273 On Linux this is typically `/etc/fish/completions`. On macOS, when
274 the fish shell is installed using Homebrew, this would normally be the
275 `etc/fish/completions` directory within the location returned by
276 the `brew --prefix` command.
277
278 * zsh:
279 +
280 Note that the `compinit` function must also be executed to enable
281 tab-completion, as described in the <<_shells>> section.
282 +
283 To load the Git LFS completion script in all sessions, store the script
284 as a file named `_git-lfs` in one of the locations listed in the `fpath`
285 variable. The specific location selected may affect whether the completion
286 script is loaded only for sessions started by the current user or for all
287 users' sessions, depending on how the set of paths in the `fpath` array
288 is constructed.
289 +
290 The following command will store the script in the first location
291 defined in `fpath`:
292 +
293 ....
294 % git lfs completion zsh >"${fpath[1]}/_git-lfs"
295 ....
296 +
297 You may also prefer to store the file in another location defined in
298 `fpath`, for instance, the last location, in which case `${fpath[-1]}`
299 should be used instead.
300 +
301 It is also possible to add a custom location to the list in `fpath`
302 and store the Git LFS completion script there. To do this, add the
303 commands that update the `fpath` variable to a startup file such as
304 `~/.zshrc` or `/etc/zshrc` so they will apply to all future sessions,
305 either for the current user or for all users.
306
307 == SEE ALSO
308
309 Part of the git-lfs(1) suite.