'\" t .\" Title: git-lfs-completion .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-03-07 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" .TH "GIT\-LFS\-COMPLETION" "1" "2024-03-07" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" git-lfs-completion \- Shell tab\-completion script generation for Git LFS .SH "SYNOPSIS" .sp \f(CRgit lfs completion bash\fP .br \f(CRgit lfs completion fish\fP .br \f(CRgit lfs completion zsh\fP .SH "DESCRIPTION" .sp Outputs a script which, when executed in a session of the given shell, will implement command\-line tab\-completion of Git LFS commands. .sp Each shell requires a different set of commands to load the completion script, either for an individual session or automatically whenever a new session is started. See the EXAMPLES section for details. .sp The script for each shell provides tab\-completion of Git LFS command names and flags, but does not offer completion of Git terms such as the names of Git remotes, branches, or tags. (This may change in a future release of Git LFS.) .sp By default, each shell\(cqs script supports Git LFS command completion when prompted with a tab character entered following the program name \f(CRgit\-lfs\fP. For instance, \f(CRgit\-lfs [Tab]\fP will list the available Git LFS commands such as \f(CRfetch\fP, \f(CRmigrate\fP, and \f(CRpull\fP, and \f(CRgit\-lfs pull \-\-[Tab]\fP will list the possible flags for the git\-lfs\-pull(1) command. .sp However, most users will be accustomed to using Git LFS as a program invoked by Git, e.g., \f(CRgit lfs checkout\fP or \f(CRgit lfs pull\fP. To enable tab\-completion of Git LFS commands in this case, tab\-completion for regular Git commands must be active as well. Assuming this is true, the scripts generated by the \f(CRgit lfs completion\fP command should support completion of Git LFS commands when a tab character is entered following \f(CRgit lfs\fP, such as \f(CRgit lfs [Tab]\fP to list all available Git LFS commands or \f(CRgit lfs pull \-\-[Tab]\fP to list that command\(cqs possible flags. See the SHELLS section for details regarding Git tab\-completion in the supported shells. .sp As is common for shell tab\-completion, a space must be entered after the \f(CRgit\-lfs\fP or \f(CRgit lfs\fP command names before the tab character will cause the Git LFS completion script to be executed. Without the space character, any active shell tab\-completion will instead search for programs whose names have a matching prefix. .sp The completion scripts make use of "hidden" Git LFS commands to request completion results from the Git LFS client, specifically the \f(CRgit lfs __complete\fP and \f(CRgit lfs __completeNoDesc\fP commands. These commands may be removed in the future, or their action may be altered without notice, and so users should not call them directly or consider them to be part of the officially documented Git LFS command\-line interface. .SH "SHELLS" .sp The \f(CRgit lfs completion\fP command supports three Unix shells, GNU Bash (Bourne Again SHell), fish, and Zsh (Z shell). Tab\-completion is configured differently in each, both in general and specifically for Git and therefore also for Git LFS. .sp On Windows, users who have Git LFS installed as part of the Git for Windows project have access to an emulation of the Bash shell which is packaged with Git for Windows. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Bash: .sp While Bash does not offer tab\-completion for Git by default, a completion script is available from the Git project, as described in the documentation: .sp .URL "https://git\-scm.com/book/en/v2/Appendix\-A%3A\-Git\-in\-Other\-Environments\-Git\-in\-Bash" "" "" .sp The script returned by the \f(CRgit lfs completion bash\fP command should be compatible with this Git completion script and allow for tab\-completion of Git LFS commands entered using either the \f(CRgit lfs\fP or \f(CRgit\-lfs\fP command formats. .sp After retrieving a copy of the Git completion script appropriate to your version of Git, run the following command to load the script in your current session: .sp .if n .RS 4 .nf .fam C $ source git\-completion.bash .fam .fi .if n .RE .sp To load the script in all future sessions, add this command to your Bash startup files, or place the file in one of the locations searched by the utilities from the bash\-completion package. .sp The bash\-completion project, which is separate from the GNU Bash shell itself, includes a large number of command completion scripts and utilities to load them automatically when starting a new session: .sp .URL "https://github.com/scop/bash\-completion" "" "" .sp The Git LFS completion script for Bash depends on several functions provided by the bash\-completion package, and so that package must be installed in order to use tab\-completion with Git LFS commands. (It is not required by the Git completion script for Bash, however.) .sp Assuming the bash\-completion package is installed, to load the Git completion script in all future sessions started by the current user (but not all users), place the \f(CRgit\-completion.bash\fP script in the \f(CRbash\-completion/completions\fP directory within the location defined by the \f(CRXDG_DATA_HOME\fP environment variable, or, if that variable is not defined, the \f(CR~/.local/share\fP directory. For example: .sp .if n .RS 4 .nf .fam C $ cp git\-completion.bash ~/.local/share/bash\-completion/completions/git .fam .fi .if n .RE .sp For the bash\-completion utilities to load the Git completion script for all users, place the Git completion script in the appropriate system directory. On Linux this may be \f(CR/usr/share/bash\-completion/completions\fP, and on macOS, when bash\-completion is installed using Homebrew, it may be the \f(CRshare/bash\-completion/completions\fP directory within the location returned by the \f(CRbrew \-\-prefix\fP command. However, these locations will vary depending on how the bash\-completion package was installed. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} fish: .sp The fish shell provides its own implementation of Git command tab\-completion, defined in a \f(CRgit.fish\fP file which is likely present by default in the list of locations the shell searches for completion scripts. .sp The script returned by the \f(CRgit lfs completion fish\fP command should be compatible with this implementation and allow for tab\-completion of Git LFS commands entered using either the \f(CRgit lfs\fP or \f(CRgit\-lfs\fP command formats. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Zsh: .sp To enable tab\-completion in Zsh for any commands, the \f(CRcompinit\fP function must be loaded first with a command similar to the following: .sp .if n .RS 4 .nf .fam C % autoload \-Uz compinit && compinit .fam .fi .if n .RE .sp This may be done individually for each session, or added to a startup file such as \f(CR~/.zshrc\fP or \f(CR/etc/zshrc\fP so it will apply to all future sessions, either for the current user or for all users. .sp Zsh reads completion functions from the locations specified in the \f(CRFPATH\fP environment variable, with the paths listed first taking precedence. This list is also available as an array in the \f(CRfpath\fP variable; the shell automatically synchronizes \f(CRFPATH\fP and \f(CRfpath\fP. .sp The Z shell provides its own implementation of Git command tab\-completion, defined in a \f(CR_git\fP file which is likely present in one of the locations specified in \f(CRfpath\fP. .sp The script returned by the \f(CRgit lfs completion zsh\fP command should be compatible with this implementation and allow for tab\-completion of Git LFS commands entered using either the \f(CRgit lfs\fP or \f(CRgit\-lfs\fP command formats. .sp The Git project also offers completion scripts for Zsh, in the form of the same \f(CRgit\-completion.bash\fP script used for the Bash shell, plus a \f(CRgit\-completion.zsh\fP script which is intended to be renamed to \f(CR_git\fP and placed in a location listed in \f(CRfpath\fP. These scripts are not compatible with the one returned by the \f(CRgit lfs completion zsh\fP command, and if they used in conjunction with that script, tab\-completion of Git LFS commands will not function properly when initiated using the \f(CRgit lfs\fP command format. .sp On macOS, if Git is installed using Homebrew, the Git project\(cqs Zsh completion scripts may be installed in a location where they take precedence over the implementation provided by Zsh. In this case, to make full use of the script returned by \f(CRgit lfs completion zsh\fP, the \f(CR_git\fP completion script file installed by Homebrew for Git must be moved or removed so it does not precede the Z shell\(cqs own Git completion script in the path order specified by \f(CRfpath\fP. .RE .SH "EXAMPLES" .SS "Loading completions for the current shell session" .sp To load Git LFS command completions for the current shell session only, execute the script generated by \f(CRgit lfs completion\fP directly. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Bash: .sp .if n .RS 4 .nf .fam C $ source <(git lfs completion bash) .fam .fi .if n .RE .sp Note that with Bash 3.2, the \f(CRsource\fP builtin command will not properly execute the output of a process substitution, and so it will be necessary to use a temporary file instead: .sp .if n .RS 4 .nf .fam C $ git lfs completion bash >git\-lfs\-completion.bash $ source git\-lfs\-completion.bash .fam .fi .if n .RE .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} fish: .sp .if n .RS 4 .nf .fam C > git lfs completion fish | source .fam .fi .if n .RE .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} zsh: .sp Note that the \f(CRcompinit\fP function must also be executed to enable tab\-completion, as described in the SHELLS section. .sp .if n .RS 4 .nf .fam C % source <(git lfs completion zsh) .fam .fi .if n .RE .RE .SS "Automatically loading completions for future shell sessions" .sp To load Git LFS command completions in all future shell sessions, store the script generated by \f(CRgit lfs completion\fP in a location where it will be read by your shell during session startup. .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} Bash: .sp As mentioned in the SHELLS section, the bash\-completion package is required by the Git LFS completion scripts for Bash, and it also provides convenient utilities which search for completion scripts in a set of defined locations and execute them during session startup. .sp To load the Git LFS completion script in all future sessions started by the current user (but not other users), store the script in the \f(CRbash\-completion/completions\fP directory within the location defined by the \f(CRXDG_DATA_HOME\fP environment variable, or, if that variable is not defined, the \f(CR~/.local/share\fP directory. For example: .sp .if n .RS 4 .nf .fam C $ mkdir \-p ~/.local/share/bash\-completion/completions $ git lfs completion bash >~/.local/share/bash\-completion/completions/git\-lfs .fam .fi .if n .RE .sp To load the completion script in all users\*(Aq future sessions, store the script instead in an appropriate system directory, which on Linux may be \f(CR/usr/share/bash\-completion/completions\fP, or on macOS, if bash\-completion was installed using Homebrew, may be the \f(CRshare/bash\-completion/completions\fP directory within the location returned by the \f(CRbrew \-\-prefix\fP command. These locations will vary depending on how the bash\-completion package was installed and configured, however. For details, check the documentation relevant to your system\(cqs bash\-completion package. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} fish: .sp The fish shell searches for completion scripts in a number of locations, as described in the documentation: .sp .URL "https://fishshell.com/docs/current/completions.html#where\-to\-put\-completions" "" "" .sp To load the Git LFS completion script in all sessions started by the current user (but not other users), store the script in the \f(CRfish/completions\fP directory within the location defined by the \f(CRXDG_CONFIG_HOME\fP environment variable, or, if that variable is not defined, the \f(CR~/.config\fP directory. For example: .sp .if n .RS 4 .nf .fam C > mkdir \-p ~/.config/fish/completions > git lfs completion fish >~/.config/fish/completions/git\-lfs.fish .fam .fi .if n .RE .sp To load the completion script in all users\*(Aq future sessions, store the script in one of the other locations searched by the shell, such under \f(CRfish/completions\fP within the shell\(cqs system configuration directory. On Linux this is typically \f(CR/etc/fish/completions\fP. On macOS, when the fish shell is installed using Homebrew, this would normally be the \f(CRetc/fish/completions\fP directory within the location returned by the \f(CRbrew \-\-prefix\fP command. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} zsh: .sp Note that the \f(CRcompinit\fP function must also be executed to enable tab\-completion, as described in the SHELLS section. .sp To load the Git LFS completion script in all sessions, store the script as a file named \f(CR_git\-lfs\fP in one of the locations listed in the \f(CRfpath\fP variable. The specific location selected may affect whether the completion script is loaded only for sessions started by the current user or for all users\*(Aq sessions, depending on how the set of paths in the \f(CRfpath\fP array is constructed. .sp The following command will store the script in the first location defined in \f(CRfpath\fP: .sp .if n .RS 4 .nf .fam C % git lfs completion zsh >"${fpath[1]}/_git\-lfs" .fam .fi .if n .RE .sp You may also prefer to store the file in another location defined in \f(CRfpath\fP, for instance, the last location, in which case \f(CR${fpath[\-1]}\fP should be used instead. .sp It is also possible to add a custom location to the list in \f(CRfpath\fP and store the Git LFS completion script there. To do this, add the commands that update the \f(CRfpath\fP variable to a startup file such as \f(CR~/.zshrc\fP or \f(CR/etc/zshrc\fP so they will apply to all future sessions, either for the current user or for all users. .RE .SH "SEE ALSO" .sp Part of the git\-lfs(1) suite.