From 41d9a6e0c264af9ea69bc5f75c0598eea9506767 Mon Sep 17 00:00:00 2001 From: Lee Butler Date: Mon, 29 Apr 2024 14:09:27 -0400 Subject: [PATCH 1/2] fix: find a suitable pager on git for windows --- git-issue.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/git-issue.sh b/git-issue.sh index b0a741a..ad70aba 100755 --- a/git-issue.sh +++ b/git-issue.sh @@ -56,6 +56,22 @@ else DATEBIN="date" fi +# Function to determine the available pager +get_pager() { + if [ -n "$PAGER" ]; then + echo "$PAGER" + elif command -v more >/dev/null 2>&1; then + echo "more" + elif command -v less >/dev/null 2>&1; then + echo "less" + else + echo "cat" + fi +} + +# Get the pager +PAGER=$(get_pager) + # Exit after displaying the specified error error() { From f16302fdab820d292067f50d65af5a4f16afaa66 Mon Sep 17 00:00:00 2001 From: Lee Butler Date: Mon, 29 Apr 2024 14:24:54 -0400 Subject: [PATCH 2/2] feature: add install script for Git for Windows use --- README.md | 8 ++++++ gfw_inst.sh | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 gfw_inst.sh diff --git a/README.md b/README.md index 11e588d..cc1d435 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,14 @@ by adding the following to your .bashrc. source ${REPO_PATH}/gi-completion.sh ``` +If you are using Git for Windows, the "make" command may not be present. You can perform installation and other operations supported by the Makefile using the +gfw_inst.sh script. For example, to +install in a personal directory/folder, you can run: +``` +PREFIX=/path/to/personal/install/ ./gfw-inst.sh install +``` +The destination should be in your PATH environment variable for commands to work. + ### Backward compatibility with the gi command For backward compatibility you can also use the original _gi_ command, by copying `gi.sh` to someplace in your path. diff --git a/gfw_inst.sh b/gfw_inst.sh new file mode 100644 index 0000000..b9d3cc1 --- /dev/null +++ b/gfw_inst.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# Set default values if not already set +PREFIX="${PREFIX:-/usr/local}" +BINPREFIX="${BINPREFIX:-$PREFIX/bin}" +LIBPREFIX="${LIBPREFIX:-$PREFIX/lib}" +MANPREFIX="${MANPREFIX:-$PREFIX/share/man/man1}" +SYSCONFDIR="${SYSCONFDIR:-$PREFIX/etc}" + +# Function to install +install_stuff() { + mkdir -p "${DESTDIR}${MANPREFIX}" + mkdir -p "${DESTDIR}${BINPREFIX}" + mkdir -p "${DESTDIR}${LIBPREFIX}/git-issue" + sed "s|/usr/local|${PREFIX}|g" git-issue.sh > git-issue + install git-issue "${DESTDIR}${BINPREFIX}/git-issue" + install lib/git-issue/import-export.sh "${DESTDIR}${LIBPREFIX}/git-issue/import-export.sh" + install -m 644 git-issue.1 "${DESTDIR}${MANPREFIX}/" + mkdir -p "${DESTDIR}${SYSCONFDIR}/bash_completion.d" + install -m 644 gi-completion.sh "${DESTDIR}${SYSCONFDIR}/bash_completion.d/git-issue" +} + +# Function to synchronize documentation +sync-docs() { + ./sync-docs.sh +} + +# Function to run tests +runtests() { + if shellcheck --version >/dev/null 2>&1 ; then + shellcheck -x *.sh lib/git-issue/*.sh + else + echo 'Skipping shellcheck; consider installing it' + fi + ./test.sh +} + +# Function to uninstall +uninstall() { + rm -f "${DESTDIR}${BINPREFIX}/git-issue" + rm -f "${DESTDIR}${MANPREFIX}/git-issue." + rm -f "${DESTDIR}${SYSCONFDIR}/bash_completion.d/git-issue" +} + +# Function to clean up files +clean() { + rm -f git-issue +} + +# Main function to handle script calling logic +main() { + case "$1" in + install) + install_stuff + ;; + sync-docs) + sync-docs + ;; + test) + runtests + ;; + uninstall) + uninstall + ;; + clean) + clean + ;; + *) + echo "Usage: $0 {install|sync-docs|test|uninstall|clean}" + exit 1 + ;; + esac +} + +# Call main with all the arguments +main "$@"