From 3f00348d5c712e1a0013bf64a08dd2ce8c8539e3 Mon Sep 17 00:00:00 2001
From: Tim <45259958+carlfriedrich@users.noreply.github.com>
Date: Sat, 18 Mar 2023 16:35:18 +0100
Subject: [PATCH] Add keybinding ctrl+y for copying stash ID in gss (#295)
---
README.md | 4 ++--
bin/git-forgit | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 2c66737..242b189 100644
--- a/README.md
+++ b/README.md
@@ -122,13 +122,13 @@ Install `forgit` in just one click.
| Alt - W | Toggle preview wrap |
| Ctrl - S | Toggle sort |
| Ctrl - R | Toggle selection |
-| Ctrl - Y | Copy commit hash* |
+| Ctrl - Y | Copy commit hash/stash ID*|
| Ctrl - K / P | Selection move up |
| Ctrl - J / N | Selection move down |
| Alt - K / P | Preview move up |
| Alt - J / N | Preview move down |
-\* Available when the selection contains a commit hash.
+\* Available when the selection contains a commit hash or a stash ID.
For linux users `FORGIT_COPY_CMD` should be set to make copy work. Example: `FORGIT_COPY_CMD='xclip -selection clipboard'`.
### ⚙ Options
diff --git a/bin/git-forgit b/bin/git-forgit
index 952028e..c101e06 100755
--- a/bin/git-forgit
+++ b/bin/git-forgit
@@ -217,6 +217,7 @@ _forgit_stash_show() {
opts="
$FORGIT_FZF_DEFAULT_OPTS
+s +m -0 --tiebreak=index --bind=\"enter:execute($cmd | $_forgit_enter_pager)\"
+ --bind=\"ctrl-y:execute-silent(echo {} | cut -d: -f1 | tr -d '[:space:]' | ${FORGIT_COPY_CMD:-pbcopy})\"
--preview=\"$cmd\"
$FORGIT_STASH_FZF_OPTS
"