Skip to content

Commit

Permalink
Add FORGIT_STASH_SHOW_PREVIEW_GIT_OPTS
Browse files Browse the repository at this point in the history
This variable can be used to tune the rendering of the stash preview.

The following example allows listing the content of the stash before
opening it.

FORGIT_STASH_SHOW_PREVIEW_GIT_OPTS="--patch-with-stat --stat-count=10"
  • Loading branch information
ccoVeille committed Apr 24, 2024
1 parent 2903fef commit 1f63c0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,20 @@ For linux users `FORGIT_COPY_CMD` should be set to make copy work. Example: `FOR
Options can be set via environment variables. They have to be **exported** in
order to be recognized by `forgit`.

For instance, if you want to order branches in `gcb` by the last committed date you could:
For instance:

- if you want to order branches in `gcb` by the last committed date, you could:

```shell
export FORGIT_CHECKOUT_BRANCH_BRANCH_GIT_OPTS='--sort=-committerdate'
```

- if you want to see a preview of the stashed items in `gss` preview, you could:

```shell
export FORGIT_STASH_SHOW_PREVIEW_GIT_OPTS="--patch-with-stat --stat-count=10"
```

## shell aliases

You can change the default aliases by defining these variables below.
Expand Down Expand Up @@ -243,7 +251,7 @@ These are passed to the according `git` calls.
| `gct` | `FORGIT_CHECKOUT_TAG_GIT_OPTS` |
| `gco` | `FORGIT_CHECKOUT_COMMIT_GIT_OPTS` |
| `grc` | `FORGIT_REVERT_COMMIT_GIT_OPTS` |
| `gss` | `FORGIT_STASH_SHOW_GIT_OPTS` |
| `gss` | `FORGIT_STASH_SHOW_GIT_OPTS`, `FORGIT_STASH_SHOW_PREVIEW_GIT_OPTS` |
| `gsp` | `FORGIT_STASH_PUSH_GIT_OPTS` |
| `gclean` | `FORGIT_CLEAN_GIT_OPTS` |
| `grb` | `FORGIT_REBASE_GIT_OPTS` |
Expand Down
4 changes: 3 additions & 1 deletion bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ _forgit_reset_head() {
_forgit_stash_show_preview() {
local stash
stash=$(echo "$1" | cut -d: -f1)
_forgit_git_stash_show "$stash" | _forgit_pager diff
_forgit_stash_show_preview_git_opts=()
_forgit_parse_array _forgit_stash_show_preview_git_opts "$FORGIT_STASH_SHOW_PREVIEW_GIT_OPTS"
_forgit_git_stash_show "${_forgit_stash_show_preview_git_opts[@]}" -- "$stash" | _forgit_pager diff
}

_forgit_git_stash_show() {
Expand Down

0 comments on commit 1f63c0a

Please sign in to comment.