mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Merge pull request #164 from wren/git-forgit-147
This commit is contained in:
commit
eb6db722cd
33
README.md
33
README.md
|
|
@ -123,6 +123,8 @@ For linux users `FORGIT_COPY_CMD` should be set to make copy work. Example: `FOR
|
|||
|
||||
#### aliases
|
||||
|
||||
##### shell
|
||||
|
||||
You can change the default aliases by defining these variables below.
|
||||
(To disable all aliases, Set the `FORGIT_NO_ALIASES` flag.)
|
||||
|
||||
|
|
@ -142,6 +144,37 @@ forgit_rebase=grb
|
|||
forgit_fixup=gfu
|
||||
```
|
||||
|
||||
#### git
|
||||
|
||||
You can use git aliases by making `git-forgit` available in `$PATH`:
|
||||
|
||||
```sh
|
||||
# after `forgit` was loaded
|
||||
export PATH="$PATH:$FORGIT_INSTALL_DIR/bin"
|
||||
```
|
||||
|
||||
*Some plugin managers can help do this.*
|
||||
|
||||
Then any forgit command will be a subcommand of git:
|
||||
|
||||
```
|
||||
$ git forgit log
|
||||
$ git forgit add
|
||||
$ git forgit diff
|
||||
```
|
||||
|
||||
Optionally you can add [aliases in git](https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases):
|
||||
|
||||
```sh
|
||||
git config --global alias.cf 'forgit checkout_file'
|
||||
```
|
||||
|
||||
And use the alias in git:
|
||||
|
||||
```sh
|
||||
git cf
|
||||
```
|
||||
|
||||
#### pagers
|
||||
|
||||
Forgit will use the default configured pager from git (`core.pager`,
|
||||
|
|
|
|||
19
bin/git-forgit
Executable file
19
bin/git-forgit
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
# This file is a bridge between forgit and git itself. This makes forgit a
|
||||
# subcommand of git, and forwards all arguments on to forgit. So, all of these
|
||||
# commands will work as expected:
|
||||
#
|
||||
# `git forgit log`
|
||||
# `git forgit checkout_file`
|
||||
# `git forgit checkout_file README.md`
|
||||
#
|
||||
# This gives users the choice to set aliases inside of their git config instead
|
||||
# of their shell config if they prefer.
|
||||
|
||||
set -e
|
||||
|
||||
source "$FORGIT_INSTALL_DIR/forgit.plugin.zsh"
|
||||
|
||||
cmd="$1"
|
||||
shift
|
||||
forgit::${cmd/_/::} "$@"
|
||||
|
|
@ -12,6 +12,8 @@ function forgit::inside_work_tree
|
|||
git rev-parse --is-inside-work-tree >/dev/null;
|
||||
end
|
||||
|
||||
set -x FORGIT_INSTALL_DIR (cd (dirname (dirname (status -f))); and pwd)
|
||||
|
||||
set -g forgit_pager "$FORGIT_PAGER"
|
||||
set -g forgit_show_pager "$FORGIT_SHOW_PAGER"
|
||||
set -g forgit_diff_pager "$FORGIT_DIFF_PAGER"
|
||||
|
|
|
|||
|
|
@ -341,3 +341,15 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
|
|||
alias "${forgit_rebase:-grb}"='forgit::rebase'
|
||||
alias "${forgit_fixup:-gfu}"='forgit::fixup'
|
||||
fi
|
||||
|
||||
# set installation path (for use by `bin/git-forgit`)
|
||||
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 "Only zsh and bash are fully supported"
|
||||
fi
|
||||
if [[ -n "$FORGIT_INSTALL_DIR" ]]; then
|
||||
export FORGIT_INSTALL_DIR
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue