gpt4 book ai didi

linux - 如何在 openBSD 上使用 git 设置自动完成?

转载 作者:太空狗 更新时间:2023-10-29 12:01:02 36 4
gpt4 key购买 nike

我想在 ksh 和 openBSD 5.8/5.9 中为 git 命令设置自动完成。
不知何故,它以前安装过,但突然消失了,所以我不得不输入或复制粘贴大量文本。

它应该像在 OSX 或 Ubuntu 中一样工作,您可以在其中键入 git merge X... 并按“tab”键以完成终端中分支名称的其余部分。

最佳答案

您需要为此编写一个脚本。 Unix/git-bash 已经有了这个脚本。

在这里阅读:https://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks https://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks#Auto-Completion

关于如何安装它,您有很多选择。只需选择适合您的方式即可。

https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion


OpenBSD 脚本

这是您可以使用的 OpenBSD 脚本的链接。
该文件的标题包含如何操作的所有说明。

http://www.ualberta.ca/dept/aict/uts/software/openbsd/ports/4.6/i386/obj/git-1.7.0/git-1.7.0/contrib/completion/git-completion.bash


以上脚本说明:

#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
# *) .git/remotes file names
# *) git 'subcommands'
# *) tree paths within 'ref:path/to/file' expressions
# *) common --long-options
#
# To use these routines:
#
# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
# 2) Added the following line to your .bashrc:
# source ~/.git-completion.sh
#
# 3) Consider changing your PS1 to also show the current branch:
# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
#
# The argument to __git_ps1 will be displayed only if you
# are currently in a git repository. The %s token will be
# the name of the current branch.
#
# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
# value, unstaged (*) and staged (+) changes will be shown next
# to the branch name. You can configure this per-repository
# with the bash.showDirtyState variable, which defaults to true
# once GIT_PS1_SHOWDIRTYSTATE is enabled.
#
# You can also see if currently something is stashed, by setting
# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
# then a '$' will be shown next to the branch name.
#
# If you would like to see if there're untracked files, then you can
# set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
# untracked files, then a '%' will be shown next to the branch name.

关于linux - 如何在 openBSD 上使用 git 设置自动完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36717623/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com