From 3c08c0fdcc8a76f0fe41d7ddbd727715284ea16e Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Mon, 12 May 2025 08:59:43 +0800 Subject: [PATCH] show branch name in bash prompt --- 93git-branch.sh | 6 ++++++ git.spec | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 93git-branch.sh diff --git a/93git-branch.sh b/93git-branch.sh new file mode 100644 index 0000000..0b09f43 --- /dev/null +++ b/93git-branch.sh @@ -0,0 +1,6 @@ +# Include the current git branch in the prompt + +if [ -f /usr/share/doc/git-core/contrib/completion/git-prompt.sh ]; then + . /usr/share/doc/git-core/contrib/completion/git-prompt.sh + PS1="$(echo -n "$PS1" | sed "s|\\\W\]|\\\W\$(type __git_ps1 >/dev/null 2>\&1 \&\& __git_ps1 \" (%s)\")\]|")" +fi diff --git a/git.spec b/git.spec index b2d59e5..f0fae79 100644 --- a/git.spec +++ b/git.spec @@ -1,11 +1,12 @@ %global gitexecdir %{_libexecdir}/git-core Name: git Version: 2.49.0 -Release: 1 +Release: 2 Summary: A popular and widely used Version Control System License: BSD-3-Clause AND GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later AND MIT URL: https://git-scm.com/ Source0: https://www.kernel.org/pub/software/scm/git/%{name}-%{version}.tar.xz +Source3: 93git-branch.sh Source100: git-gui.desktop Source101: git@.service.in @@ -169,6 +170,13 @@ install -p -m 644 gitweb/README %{buildroot}%{_pkgdocdir}/README.gitweb install -Dpm 644 contrib/completion/git-completion.bash %{buildroot}%{_datadir}/bash-completion/completions/git ln -s git %{buildroot}%{_datadir}/bash-completion/completions/gitk +# Copy the whole contrib dir as docs. It contains useful scripts. +mkdir -p %{buildroot}%{_datadir}/doc/git-core +cp -ar contrib %{buildroot}%{_datadir}/doc/git-core + +# And the prompt manipulation file +install -Dpm 0644 %{S:3} %{buildroot}%{_sysconfdir}/profile.d/93git-branch.sh + # install contrib to git-core mkdir -p %{buildroot}%{_datadir}/git-core/contrib/completion install -p -m 644 contrib/completion/git-completion.tcsh %{buildroot}%{_datadir}/git-core/contrib/completion/ @@ -237,12 +245,14 @@ grep -E "$not_core_re" bin-man-doc-files > git-bin-files %files core -f bin-files-core -f %{name}.lang %license LGPL-2.1 COPYING +%{_docdir}/git-core # exclude is best way here because of troubles with symlinks inside git-core/ %exclude %{_datadir}/git-core/templates/hooks/fsmonitor-watchman.sample %exclude %{_datadir}/git-core/templates/hooks/pre-rebase.sample %exclude %{_datadir}/git-core/templates/hooks/prepare-commit-msg.sample %{_datadir}/bash-completion/completions %{_datadir}/git-core/ +%{_sysconfdir}/profile.d/93git-branch.sh %files daemon %{_unitdir}/git.socket @@ -285,6 +295,9 @@ grep -E "$not_core_re" bin-man-doc-files > git-bin-files %{_mandir}/man7/git*.7.* %changelog +* Mon May 12 2025 Funda Wang - 2.49.0-2 +- show branch name in bash prompt + * Sat Mar 15 2025 Funda Wang - 2.49.0-1 - update to 2.49.0 -- Gitee