From f17b7eefc0d739cb49aa585c3be155c4c15a8721 Mon Sep 17 00:00:00 2001 From: sandroid Date: Sat, 9 Dec 2023 02:07:37 +0100 Subject: [PATCH] Remove deferred execution in _forgit_stash_show --- bin/git-forgit | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/git-forgit b/bin/git-forgit index 4231f66..a42dea9 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -84,6 +84,16 @@ _forgit_yank_sha() { echo "$1" | _forgit_extract_sha | ${FORGIT_COPY_CMD:-pbcopy} } +# extract the first stash name in the input +_forgit_extract_stash_name() { + cut -d: -f1 | tr -d '[:space:]' +} + +# extract the first stash name and copy it to the clipboard +_forgit_yank_stash_name() { + echo "$1" | _forgit_extract_stash_name | ${FORGIT_COPY_CMD:-pbcopy} +} + # parse a space separated string into an array # arrays parsed with this function are global _forgit_parse_array() { @@ -382,7 +392,7 @@ _forgit_stash_show() { opts=" $FORGIT_FZF_DEFAULT_OPTS +s +m -0 --tiebreak=index --bind=\"enter:execute($FORGIT stash_show_preview {} | $_forgit_enter_pager)\" - --bind=\"ctrl-y:execute-silent(echo {} | cut -d: -f1 | tr -d '[:space:]' | ${FORGIT_COPY_CMD:-pbcopy})\" + --bind=\"ctrl-y:execute-silent($FORGIT yank_stash_name {})\" --preview=\"$FORGIT stash_show_preview {}\" $FORGIT_STASH_FZF_OPTS " @@ -940,6 +950,7 @@ private_commands=( "stash_push_preview" "stash_show_preview" "yank_sha" + "yank_stash_name" "log_preview" "log_enter" "exec_diff"