From 1f63c0af2ab92a8d16a5912d9e8d314ccf19813b Mon Sep 17 00:00:00 2001 From: ccoVeille <3875889+ccoVeille@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:37:51 +0200 Subject: [PATCH] Add FORGIT_STASH_SHOW_PREVIEW_GIT_OPTS 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" --- README.md | 12 ++++++++++-- bin/git-forgit | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a6437add..79411c10 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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` | diff --git a/bin/git-forgit b/bin/git-forgit index c10b7b38..496ebd2e 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -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() {