add handling for standalone version of forgit (for use in git commands)

This commit is contained in:
Jonathan Wren 2021-10-17 22:27:51 -07:00
parent 8107352941
commit 896aaa44a4
2 changed files with 23 additions and 0 deletions

8
bin/git-forgit Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
source "$FORGIT_INSTALL_DIR/forgit.plugin.zsh"
cmd="$1"
shift
forgit::${cmd/-/::} "$@"

View file

@ -333,3 +333,18 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
alias "${forgit_rebase:-grb}"='forgit::rebase'
alias "${forgit_fixup:-gfu}"='forgit::fixup'
fi
if [[ -n "$FORGIT_STANDALONE" ]]; then
if [[ -n "$ZSH_VERSION" ]]; then
FORGIT_INSTALL_DIR="$( dirname -- "$0")"
elif [[ -n "$BASH_VERSION" ]]; then
FORGIT_INSTALL_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
else
forgit::warn "Shell not supported for FORGIT_STANDLONE (only zsh and bash)"
fi
if [[ -n "$FORGIT_INSTALL_DIR" ]]; then
export FORGIT_INSTALL_DIR
fi
fi