From 601fbe14901d578f46117860a646a00e5f52b3cb Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 11 Jul 2024 01:35:42 -0700 Subject: [PATCH 01/15] feat(issue): add live search mode using github syntax --- gh-fzf | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gh-fzf b/gh-fzf index 13ca7ab..e0efb61 100755 --- a/gh-fzf +++ b/gh-fzf @@ -214,7 +214,16 @@ $global_binds fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \ --header="$issue_header" \ - --bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \ + --prompt="Find Issues > " \ + --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ + --bind 'change:reload-sync:sleep 0.25; $FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true' \ + --bind 'alt-/:transform:[[ ! $FZF_PROMPT =~ Search ]] && + echo "rebind(change)+change-prompt(Search Issues > )+disable-search+transform-query( + echo \{q} > /tmp/gh-fzf-issue-query-f; cat /tmp/gh-fzf-issue-query-s + )" || + echo "unbind(change)+change-prompt(Find Issues > )+enable-search+transform-query( + echo \{q} > /tmp/gh-fzf-issue-query-s; cat /tmp/gh-fzf-issue-query-f + )"' \ --bind="ctrl-o:execute-silent(gh issue view --web {1} $REPO_FLAG &)+refresh-preview" \ --bind="ctrl-y:execute-silent(gh fzf util copy-url issue {1})+refresh-preview" \ --bind="enter:execute(gh issue edit {1} $REPO_FLAG)+refresh-preview" \ @@ -224,9 +233,9 @@ $global_binds --bind='alt-L:execute(gh fzf util select-labels remove issue {1})+refresh-preview' \ --bind="alt-O:execute(gh issue reopen {1} $REPO_FLAG)+refresh-preview" \ --bind="alt-X:execute(gh issue close {1} $REPO_FLAG)+refresh-preview" \ - --bind='alt-M:execute(gh fzf milestone > /tmp/gh-fzf-milestone)+reload( - m="$(cat /tmp/gh-fzf-milestone)" - rm -f /tmp/gh-fzf-milestone; + --bind='alt-M:execute(gh fzf milestone > /tmp/gh-fzf-issue-milestone)+reload( + m="$(cat /tmp/gh-fzf-issue-milestone)" + rm -f /tmp/gh-fzf-issue-milestone; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" )' \ --bind='alt-a:reload(eval "$FZF_DEFAULT_COMMAND --assignee @me")' \ From af8dc37dd928375432dfd693ecb41b5a464c7c6a Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 11 Jul 2024 03:57:24 -0700 Subject: [PATCH 02/15] feat(ui): change fzf border style to use less screen space --- gh-fzf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gh-fzf b/gh-fzf index e0efb61..bdd3e06 100755 --- a/gh-fzf +++ b/gh-fzf @@ -124,8 +124,8 @@ fi # The following fzf options are shared by all commands. They are prepended to # the FZF_DEFAULT_OPTS environment variable so they can be overridden by users. export FZF_DEFAULT_OPTS=' ---no-hscroll --no-exit-0 --header-lines=1 --cycle --reverse --delimiter=" " ---preview-window="right,50%,wrap,~2,<60(down,40%,wrap)" +--no-hscroll --no-exit-0 --header-lines=1 --cycle +--preview-window="right,border-left,50%,wrap,~2,<60(down,border-top,40%,wrap)" --preview-label="(alt+P: toggle preview) (alt+H: toggle hints)" --bind="alt-P:toggle-preview" --bind="alt-H:toggle-header" --color "fg:#ebdbb2,fg+:#ebdbb2,bg:#282828,bg+:#3c3836,hl:#d3869b:bold,hl+:#d3869b,info:#83a598,prompt:#bdae93,spinner:#fabd2f,pointer:#83a598,marker:#fe8019,header:#928374,label:#83a598" @@ -140,7 +140,7 @@ export FZF_DEFAULT_OPTS=' --bind="alt-7:reload(eval \"$FZF_DEFAULT_COMMAND -L700\")" --bind="alt-8:reload(eval \"$FZF_DEFAULT_COMMAND -L800\")" --bind="alt-9:reload(eval \"$FZF_DEFAULT_COMMAND -L900\")" -'"$FZF_DEFAULT_OPTS"' --no-select-1 --ansi --no-multi' +'"$FZF_DEFAULT_OPTS"' --no-select-1 --ansi --reverse --no-multi --delimiter=" "' # Overriding the three options above breaks gh-fzf, so append them instead. # ----------------------------------------------------------------------1}}} From 795a42913b526ad9578805515f7b762abf05caee Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 11 Jul 2024 03:58:15 -0700 Subject: [PATCH 03/15] fix(issue): use border label to store search mode state --- gh-fzf | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/gh-fzf b/gh-fzf index bdd3e06..3d65eaf 100755 --- a/gh-fzf +++ b/gh-fzf @@ -28,6 +28,8 @@ set -e +trap 'rm -f ${TMPDIR:-/tmp}/gh-fzf-*' SIGINT SIGTERM EXIT + GH_FZF_VERSION="v0.13.0" # x-release-please-version # USAGE INFO AND LOGS {{{1 @@ -210,19 +212,26 @@ $global_binds " # FZF COMMAND {{{2 - FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT $*" \ + ISSUE_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT" + + FZF_DEFAULT_COMMAND="$ISSUE_COMMAND $*" \ fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \ --header="$issue_header" \ - --prompt="Find Issues > " \ + --prompt="issues $* > " \ + --border="bottom" \ + --border-label="[mode: fzf] " \ + --border-label-pos=-99999 \ --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ - --bind 'change:reload-sync:sleep 0.25; $FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true' \ - --bind 'alt-/:transform:[[ ! $FZF_PROMPT =~ Search ]] && - echo "rebind(change)+change-prompt(Search Issues > )+disable-search+transform-query( - echo \{q} > /tmp/gh-fzf-issue-query-f; cat /tmp/gh-fzf-issue-query-s + --bind "change:reload-sync:sleep 0.25; $ISSUE_COMMAND $* \${FZF_QUERY:+-S {q}} || true" \ + --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( + echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; + cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh )" || - echo "unbind(change)+change-prompt(Find Issues > )+enable-search+transform-query( - echo \{q} > /tmp/gh-fzf-issue-query-s; cat /tmp/gh-fzf-issue-query-f + echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( + echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh; + cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf )"' \ --bind="ctrl-o:execute-silent(gh issue view --web {1} $REPO_FLAG &)+refresh-preview" \ --bind="ctrl-y:execute-silent(gh fzf util copy-url issue {1})+refresh-preview" \ @@ -235,7 +244,7 @@ $global_binds --bind="alt-X:execute(gh issue close {1} $REPO_FLAG)+refresh-preview" \ --bind='alt-M:execute(gh fzf milestone > /tmp/gh-fzf-issue-milestone)+reload( m="$(cat /tmp/gh-fzf-issue-milestone)" - rm -f /tmp/gh-fzf-issue-milestone; + rm -f /${TMPDIR:-/tmp}/gh-fzf-issue-milestone; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" )' \ --bind='alt-a:reload(eval "$FZF_DEFAULT_COMMAND --assignee @me")' \ From 3413f78515090bc062a87f45f0ed466a1c35ab1d Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 11 Jul 2024 05:26:32 -0700 Subject: [PATCH 04/15] refactor: add additional mode indicator --- gh-fzf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gh-fzf b/gh-fzf index 3d65eaf..42f2bf8 100755 --- a/gh-fzf +++ b/gh-fzf @@ -218,18 +218,18 @@ $global_binds fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \ --header="$issue_header" \ - --prompt="issues $* > " \ + --prompt="issues${*:+ $*} ❯ " \ --border="bottom" \ --border-label="[mode: fzf] " \ --border-label-pos=-99999 \ --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ --bind "change:reload-sync:sleep 0.25; $ISSUE_COMMAND $* \${FZF_QUERY:+-S {q}} || true" \ --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && - echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( + echo "rebind(change)+change-prompt(issues'"${*:+ $*}"' ❱ )+change-border-label([mode: gh] )+disable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh )" || - echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( + echo "unbind(change)+change-prompt(issues'"${*:+ $*}"' ❯ )+change-border-label([mode: fzf] )+enable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf )"' \ From 9c8c39d154555f02f04c5256fc147deda4dd59ce Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Thu, 11 Jul 2024 19:57:25 -0700 Subject: [PATCH 05/15] feat(issue): improve filter keybind behavior during live search --- gh-fzf | 62 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/gh-fzf b/gh-fzf index 42f2bf8..fb87c06 100755 --- a/gh-fzf +++ b/gh-fzf @@ -28,8 +28,6 @@ set -e -trap 'rm -f ${TMPDIR:-/tmp}/gh-fzf-*' SIGINT SIGTERM EXIT - GH_FZF_VERSION="v0.13.0" # x-release-please-version # USAGE INFO AND LOGS {{{1 @@ -168,6 +166,9 @@ default_cmd() { # COMMAND > ISSUE {{{1 issue_cmd() { + # make sure state from the previous execution is destroyed + rm -f /tmp/gh-fzf-issue-* + # GO TEMPLATE {{{2 issue_template='\ --json "number,title,author,assignees,state,milestone,labels,updatedAt" \ @@ -218,18 +219,18 @@ $global_binds fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \ --header="$issue_header" \ - --prompt="issues${*:+ $*} ❯ " \ + --prompt="issues${*:+ $*} ❱ " \ --border="bottom" \ --border-label="[mode: fzf] " \ --border-label-pos=-99999 \ --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ --bind "change:reload-sync:sleep 0.25; $ISSUE_COMMAND $* \${FZF_QUERY:+-S {q}} || true" \ --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && - echo "rebind(change)+change-prompt(issues'"${*:+ $*}"' ❱ )+change-border-label([mode: gh] )+disable-search+transform-query( + echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh )" || - echo "unbind(change)+change-prompt(issues'"${*:+ $*}"' ❯ )+change-border-label([mode: fzf] )+enable-search+transform-query( + echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf )"' \ @@ -242,15 +243,36 @@ $global_binds --bind='alt-L:execute(gh fzf util select-labels remove issue {1})+refresh-preview' \ --bind="alt-O:execute(gh issue reopen {1} $REPO_FLAG)+refresh-preview" \ --bind="alt-X:execute(gh issue close {1} $REPO_FLAG)+refresh-preview" \ - --bind='alt-M:execute(gh fzf milestone > /tmp/gh-fzf-issue-milestone)+reload( - m="$(cat /tmp/gh-fzf-issue-milestone)" - rm -f /${TMPDIR:-/tmp}/gh-fzf-issue-milestone; + --bind='alt-M:execute( + rm -f "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; + gh fzf milestone > "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; + )+transform-prompt( + echo "issues'"${*:+ $*}"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❯ " + )+reload( + m="$(cat ${TMPDIR:-/tmp}/gh-fzf-issue-milestone)"; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" )' \ - --bind='alt-a:reload(eval "$FZF_DEFAULT_COMMAND --assignee @me")' \ - --bind='alt-A:reload(eval "$FZF_DEFAULT_COMMAND --author @me")' \ - --bind='alt-m:reload(eval "$FZF_DEFAULT_COMMAND --mention @me")' \ - --bind='alt-s:reload(eval "$FZF_DEFAULT_COMMAND --state all")' + --bind 'alt-a:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" + )+change-prompt:issues'"${*:+ $*}"' --assignee @me ❯ " || + [[ ! $FZF_QUERY =~ assignee:@me ]] && echo "put( assignee:@me)" + )' \ + --bind 'alt-A:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --author @me\" + )+change-prompt:issues'"${*:+ $*}"' --author @me ❯ " || + [[ ! $FZF_QUERY =~ author:@me ]] && echo "put( author:@me)" + )' \ + --bind 'alt-m:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --mention @me\" + )+change-prompt:issues'"${*:+ $*}"' --mention @me ❯ " || + [[ ! $FZF_QUERY =~ mention:@me ]] && echo "put( mention:@me)" + )' \ + --bind 'alt-s:reload( + eval "$FZF_DEFAULT_COMMAND --state all" + )+change-prompt:issues'"${*:+ $*}"' --state all ❯ ' #2}}} } @@ -261,13 +283,14 @@ $global_binds pr_cmd() { # GO TEMPLATE {{{2 pr_template='\ - --json "number,title,state,headRefName,milestone,updatedAt,labels" \ + --json "number,title,state,headRefName,milestone,updatedAt,labels,additions,deletions,changedFiles" \ --template '\'' {{- $headerColor := "blue+b" -}} {{- tablerow ("PR" | autocolor $headerColor) ("LAST UPDATE" | autocolor $headerColor) ("TITLE" | autocolor $headerColor) + ("DIFF STAT" | autocolor $headerColor) ("BRANCH" | autocolor $headerColor) ("LABELS" | autocolor $headerColor) ("MILESTONE" | autocolor $headerColor) @@ -289,10 +312,15 @@ pr_cmd() { {{- tablerow (printf "#%v" .number | autocolor $stateColor) ((timeago .updatedAt) | autocolor "white+d") - (truncate 100 (.title | autocolor "white+h")) - (truncate 60 (.headRefName | autocolor "white+d")) - (pluck "name" .labels | join ", " | autocolor "white+h") - ($milestoneTitle | autocolor "white+d") + (truncate 90 (.title | autocolor "white+h")) + (printf "%s %s %s" + (printf "+%v" .additions | autocolor "green+d") + (printf "-%v" .deletions | autocolor "red+d") + (printf "(%v files)" .changedFiles | autocolor "white+d") + ) + (truncate 60 (.headRefName | autocolor "white+h")) + (pluck "name" .labels | join ", " | autocolor "white+d") + ($milestoneTitle | autocolor "white+h") -}} {{- end -}} '\''' From 2abc217205288892cfafccb0d9093882cc584bcc Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Fri, 12 Jul 2024 01:15:03 -0700 Subject: [PATCH 06/15] feat(issue): make `ctrl-r` keybind reset the live search state --- gh-fzf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gh-fzf b/gh-fzf index 33592be..9851e3f 100755 --- a/gh-fzf +++ b/gh-fzf @@ -229,11 +229,14 @@ $global_binds echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh - )" || + )+change-prompt(issues'"${*:+ $*}"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf )"' \ + --bind='ctrl-r:change-prompt(issues'"${*:+ $*}"' ❱ )+execute-silent( + rm -f ${TMPDIR:-/tmp}/gh-fzf-issue-query-* + )+clear-query+first+reload(eval "$FZF_DEFAULT_COMMAND")' \ --bind="ctrl-o:execute-silent(gh issue view --web {1} $REPO_FLAG &)+refresh-preview" \ --bind="ctrl-y:execute-silent(gh fzf util copy-url issue {1})+refresh-preview" \ --bind="enter:execute(gh issue edit {1} $REPO_FLAG)+refresh-preview" \ From 51070aec7db03339751627060ef20c8e78bce94b Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Fri, 12 Jul 2024 01:15:59 -0700 Subject: [PATCH 07/15] fix(issue): use the same trailing character for the prompt --- gh-fzf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gh-fzf b/gh-fzf index 9851e3f..6a42809 100755 --- a/gh-fzf +++ b/gh-fzf @@ -250,7 +250,7 @@ $global_binds rm -f "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; gh fzf milestone > "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; )+transform-prompt( - echo "issues'"${*:+ $*}"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❯ " + echo "issues'"${*:+ $*}"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❱ " )+reload( m="$(cat ${TMPDIR:-/tmp}/gh-fzf-issue-milestone)"; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" @@ -258,24 +258,24 @@ $global_binds --bind 'alt-a:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" - )+change-prompt:issues'"${*:+ $*}"' --assignee @me ❯ " || + )+change-prompt:issues'"${*:+ $*}"' --assignee @me ❱ " || [[ ! $FZF_QUERY =~ assignee:@me ]] && echo "put( assignee:@me)" )' \ --bind 'alt-A:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --author @me\" - )+change-prompt:issues'"${*:+ $*}"' --author @me ❯ " || + )+change-prompt:issues'"${*:+ $*}"' --author @me ❱ " || [[ ! $FZF_QUERY =~ author:@me ]] && echo "put( author:@me)" )' \ --bind 'alt-m:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --mention @me\" - )+change-prompt:issues'"${*:+ $*}"' --mention @me ❯ " || + )+change-prompt:issues'"${*:+ $*}"' --mention @me ❱ " || [[ ! $FZF_QUERY =~ mention:@me ]] && echo "put( mention:@me)" )' \ --bind 'alt-s:reload( eval "$FZF_DEFAULT_COMMAND --state all" - )+change-prompt:issues'"${*:+ $*}"' --state all ❯ ' + )+change-prompt:issues'"${*:+ $*}"' --state all ❱ ' #2}}} } From a14c97f7bc9e2b5d98d773b4f9e0cab30dbc9493 Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Fri, 12 Jul 2024 01:26:18 -0700 Subject: [PATCH 08/15] chore: cleanup --- gh-fzf | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/gh-fzf b/gh-fzf index 6a42809..b844e46 100755 --- a/gh-fzf +++ b/gh-fzf @@ -170,7 +170,7 @@ issue_cmd() { rm -f /tmp/gh-fzf-issue-* # GO TEMPLATE {{{2 - issue_template='\ + ISSUE_TEMPLATE='\ --json "number,title,author,assignees,state,milestone,labels,updatedAt" \ --template '\'' {{- $headerColor := "blue+b" -}} @@ -206,20 +206,22 @@ issue_cmd() { '\''' # KEYBINDING HINTS {{{2 - issue_header="Actions > (enter: edit) (alt-c: comment) (alt-o: checkout) (alt-l: add labels) (alt-L: remove labels) (alt-X: close) (alt-O: reopen) + ISSUE_HEADER="Actions > (enter: edit) (alt-c: comment) (alt-o: checkout) (alt-l: add labels) (alt-L: remove labels) (alt-X: close) (alt-O: reopen) Filters > (alt-a: assignee) (alt-A: author) (alt-m: mention) (alt-M: milestone) (alt-s: state=all) $global_binds " - # FZF COMMAND {{{2 - ISSUE_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT" + # INITIAL STATE {{{2 + ISSUE_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh issue list $ISSUE_TEMPLATE -L $GH_FZF_DEFAULT_LIMIT" + ISSUE_PROMPT="issues${*:+ $*}" + # FZF COMMAND {{{2 FZF_DEFAULT_COMMAND="$ISSUE_COMMAND $*" \ fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \ - --header="$issue_header" \ - --prompt="issues${*:+ $*} ❱ " \ + --header="$ISSUE_HEADER" \ + --prompt="$ISSUE_PROMPT ❱ " \ --border="bottom" \ --border-label="[mode: fzf] " \ --border-label-pos=-99999 \ @@ -229,12 +231,12 @@ $global_binds echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh - )+change-prompt(issues'"${*:+ $*}"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || + )+change-prompt('"$ISSUE_PROMPT"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf )"' \ - --bind='ctrl-r:change-prompt(issues'"${*:+ $*}"' ❱ )+execute-silent( + --bind='ctrl-r:change-prompt('"$ISSUE_PROMPT"' ❱ )+execute-silent( rm -f ${TMPDIR:-/tmp}/gh-fzf-issue-query-* )+clear-query+first+reload(eval "$FZF_DEFAULT_COMMAND")' \ --bind="ctrl-o:execute-silent(gh issue view --web {1} $REPO_FLAG &)+refresh-preview" \ @@ -250,7 +252,7 @@ $global_binds rm -f "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; gh fzf milestone > "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; )+transform-prompt( - echo "issues'"${*:+ $*}"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❱ " + echo "'"$ISSUE_PROMPT"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❱ " )+reload( m="$(cat ${TMPDIR:-/tmp}/gh-fzf-issue-milestone)"; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" @@ -258,24 +260,24 @@ $global_binds --bind 'alt-a:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" - )+change-prompt:issues'"${*:+ $*}"' --assignee @me ❱ " || + )+change-prompt:'"$ISSUE_PROMPT"' --assignee @me ❱ " || [[ ! $FZF_QUERY =~ assignee:@me ]] && echo "put( assignee:@me)" )' \ --bind 'alt-A:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --author @me\" - )+change-prompt:issues'"${*:+ $*}"' --author @me ❱ " || + )+change-prompt:'"$ISSUE_PROMPT"' --author @me ❱ " || [[ ! $FZF_QUERY =~ author:@me ]] && echo "put( author:@me)" )' \ --bind 'alt-m:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --mention @me\" - )+change-prompt:issues'"${*:+ $*}"' --mention @me ❱ " || + )+change-prompt:'"$ISSUE_PROMPT"' --mention @me ❱ " || [[ ! $FZF_QUERY =~ mention:@me ]] && echo "put( mention:@me)" )' \ --bind 'alt-s:reload( eval "$FZF_DEFAULT_COMMAND --state all" - )+change-prompt:issues'"${*:+ $*}"' --state all ❱ ' + )+change-prompt:'"$ISSUE_PROMPT"' --state all ❱ ' #2}}} } From 6cd96b6bb139c6fd12a94c66d4e3aaa07bd1453e Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sat, 13 Jul 2024 02:09:51 -0700 Subject: [PATCH 09/15] style(issue): lowercase command-specific variables --- gh-fzf | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gh-fzf b/gh-fzf index 93b97e2..49c808f 100755 --- a/gh-fzf +++ b/gh-fzf @@ -170,7 +170,7 @@ issue_cmd() { rm -f /tmp/gh-fzf-issue-* # GO TEMPLATE {{{2 - ISSUE_TEMPLATE='\ + issue_template='\ --json "number,title,author,assignees,state,milestone,labels,updatedAt" \ --template '\'' {{- $headerColor := "blue+b" -}} @@ -206,37 +206,37 @@ issue_cmd() { '\''' # KEYBINDING HINTS {{{2 - ISSUE_HEADER="Actions > (enter: edit) (alt-c: comment) (alt-o: checkout) (alt-l: add labels) (alt-L: remove labels) (alt-X: close) (alt-O: reopen) + issue_header="Actions > (enter: edit) (alt-c: comment) (alt-o: checkout) (alt-l: add labels) (alt-L: remove labels) (alt-X: close) (alt-O: reopen) Filters > (alt-a: assignee) (alt-A: author) (alt-m: mention) (alt-M: milestone) (alt-s: state=all) $global_binds " # INITIAL STATE {{{2 - ISSUE_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh issue list $ISSUE_TEMPLATE -L $GH_FZF_DEFAULT_LIMIT" - ISSUE_PROMPT="issues${*:+ $*}" + issue_command="GH_FORCE_TTY=$GH_COLUMNS gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT" + issue_prompt="issues${*:+ $*}" # FZF COMMAND {{{2 - FZF_DEFAULT_COMMAND="$ISSUE_COMMAND $*" \ + FZF_DEFAULT_COMMAND="$issue_command $*" \ fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \ - --header="$ISSUE_HEADER" \ - --prompt="$ISSUE_PROMPT ❱ " \ + --header="$issue_header" \ + --prompt="$issue_prompt ❱ " \ --border="bottom" \ --border-label="[mode: fzf] " \ --border-label-pos=-99999 \ --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ - --bind "change:reload-sync:sleep 0.25; $ISSUE_COMMAND $* \${FZF_QUERY:+-S {q}} || true" \ + --bind "change:reload-sync:sleep 0.25; $issue_command $* \${FZF_QUERY:+-S {q}} || true" \ --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh - )+change-prompt('"$ISSUE_PROMPT"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || + )+change-prompt('"$issue_prompt"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-gh; cat ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf )"' \ - --bind='ctrl-r:change-prompt('"$ISSUE_PROMPT"' ❱ )+execute-silent( + --bind='ctrl-r:change-prompt('"$issue_prompt"' ❱ )+execute-silent( rm -f ${TMPDIR:-/tmp}/gh-fzf-issue-query-* )+clear-query+first+reload(eval "$FZF_DEFAULT_COMMAND")' \ --bind="ctrl-o:execute-silent(gh issue view --web {1} $REPO_FLAG &)+refresh-preview" \ @@ -252,7 +252,7 @@ $global_binds rm -f "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; gh fzf milestone > "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; )+transform-prompt( - echo "'"$ISSUE_PROMPT"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❱ " + echo "'"$issue_prompt"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❱ " )+reload( m="$(cat ${TMPDIR:-/tmp}/gh-fzf-issue-milestone)"; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" @@ -260,24 +260,24 @@ $global_binds --bind 'alt-a:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" - )+change-prompt:'"$ISSUE_PROMPT"' --assignee @me ❱ " || + )+change-prompt:'"$issue_prompt"' --assignee @me ❱ " || [[ ! $FZF_QUERY =~ assignee:@me ]] && echo "put( assignee:@me)" )' \ --bind 'alt-A:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --author @me\" - )+change-prompt:'"$ISSUE_PROMPT"' --author @me ❱ " || + )+change-prompt:'"$issue_prompt"' --author @me ❱ " || [[ ! $FZF_QUERY =~ author:@me ]] && echo "put( author:@me)" )' \ --bind 'alt-m:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --mention @me\" - )+change-prompt:'"$ISSUE_PROMPT"' --mention @me ❱ " || + )+change-prompt:'"$issue_prompt"' --mention @me ❱ " || [[ ! $FZF_QUERY =~ mention:@me ]] && echo "put( mention:@me)" )' \ --bind 'alt-s:reload( eval "$FZF_DEFAULT_COMMAND --state all" - )+change-prompt:'"$ISSUE_PROMPT"' --state all ❱ ' + )+change-prompt:'"$issue_prompt"' --state all ❱ ' #2}}} } From c11764205aa9cc934f0ddbc94c2302ee4274276d Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sat, 13 Jul 2024 04:46:44 -0700 Subject: [PATCH 10/15] fix(issue) add state filter to query in gh mode --- gh-fzf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gh-fzf b/gh-fzf index 49c808f..ea65aa1 100755 --- a/gh-fzf +++ b/gh-fzf @@ -274,10 +274,16 @@ $global_binds eval \"\$FZF_DEFAULT_COMMAND --mention @me\" )+change-prompt:'"$issue_prompt"' --mention @me ❱ " || [[ ! $FZF_QUERY =~ mention:@me ]] && echo "put( mention:@me)" - )' \ - --bind 'alt-s:reload( - eval "$FZF_DEFAULT_COMMAND --state all" - )+change-prompt:'"$issue_prompt"' --state all ❱ ' + ' \ + --bind 'alt-s:transform:if [[ ! $FZF_BORDER_LABEL =~ gh ]]; then + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --state all\" + )+change-prompt:'"$issue_prompt"' --state all ❱ " + else + [[ ! $FZF_QUERY =~ state:open ]] && act="put( state:open)" + [[ ! $FZF_QUERY =~ state:closed ]] && act="${act:+$act+}put( state:closed)" + echo "$act" + fi' #2}}} } From 7be838876725ad0594fd97e464cac5a9da4d8ee6 Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sat, 13 Jul 2024 04:47:17 -0700 Subject: [PATCH 11/15] fix(issue): resolve invalid transform action syntax --- gh-fzf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gh-fzf b/gh-fzf index ea65aa1..94c611d 100755 --- a/gh-fzf +++ b/gh-fzf @@ -257,19 +257,19 @@ $global_binds m="$(cat ${TMPDIR:-/tmp}/gh-fzf-issue-milestone)"; eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" )' \ - --bind 'alt-a:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && + --bind 'alt-a:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" )+change-prompt:'"$issue_prompt"' --assignee @me ❱ " || [[ ! $FZF_QUERY =~ assignee:@me ]] && echo "put( assignee:@me)" - )' \ - --bind 'alt-A:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && + ' \ + --bind 'alt-A:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --author @me\" )+change-prompt:'"$issue_prompt"' --author @me ❱ " || [[ ! $FZF_QUERY =~ author:@me ]] && echo "put( author:@me)" - )' \ - --bind 'alt-m:transform:([[ ! $FZF_BORDER_LABEL =~ gh ]] && + ' \ + --bind 'alt-m:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --mention @me\" )+change-prompt:'"$issue_prompt"' --mention @me ❱ " || From fcdd29a61d7a2a10595bab3984ea44560793709c Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sat, 13 Jul 2024 04:48:28 -0700 Subject: [PATCH 12/15] feat(pr): add mode to live query via github search syntax --- gh-fzf | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/gh-fzf b/gh-fzf index 94c611d..d0f1115 100755 --- a/gh-fzf +++ b/gh-fzf @@ -292,6 +292,8 @@ $global_binds # COMMAND > PR {{{1 pr_cmd() { + # make sure state from the previous execution is destroyed + rm -f /tmp/gh-fzf-pr-* # GO TEMPLATE {{{2 pr_template='\ --json "number,title,state,headRefName,milestone,updatedAt,labels,additions,deletions,changedFiles" \ @@ -343,12 +345,33 @@ Filters > (alt-a: assignee) (alt-A: author) (alt-b: branch) (alt-s: state=all) $global_binds " + # INITIAL STATE {{{2 + pr_command="GH_FORCE_TTY=$GH_COLUMNS gh pr list $pr_template -L $GH_FZF_DEFAULT_LIMIT" + pr_prompt="prs${*:+ $*}" + # FZF COMMAND {{{2 - FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh pr list $pr_template -L $GH_FZF_DEFAULT_LIMIT $*" \ + FZF_DEFAULT_COMMAND="$pr_command $*" \ fzf \ --preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh pr view {1} --comments '"$REPO_FLAG" \ --header="$pr_header" \ - --bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \ + --prompt="$pr_prompt ❱ " \ + --border="bottom" \ + --border-label="[mode: fzf] " \ + --border-label-pos=-99999 \ + --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ + --bind "change:reload-sync:sleep 0.25; $pr_command $* \${FZF_QUERY:+-S {q}} || true" \ + --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( + echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-pr-query-fzf; + cat ${TMPDIR:-/tmp}/gh-fzf-pr-query-gh + )+change-prompt('"$pr_prompt"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || + echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( + echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-pr-query-gh; + cat ${TMPDIR:-/tmp}/gh-fzf-pr-query-fzf + )"' \ + --bind='ctrl-r:change-prompt('"$pr_prompt"' ❱ )+execute-silent( + rm -f ${TMPDIR:-/tmp}/gh-fzf-pr-query-* + )+clear-query+first+reload(eval "$FZF_DEFAULT_COMMAND")' \ --bind="ctrl-o:execute-silent(gh pr view --web {1} $REPO_FLAG &)+refresh-preview" \ --bind="ctrl-y:execute-silent(gh fzf util copy-url pr {1})+refresh-preview" \ --bind="alt-y:execute-silent( @@ -368,11 +391,35 @@ $global_binds --bind="alt-M:execute(gh pr merge {1} $REPO_FLAG)+refresh-preview" \ --bind="alt-O:execute(gh pr reopen {1} $REPO_FLAG)+refresh-preview" \ --bind="alt-X:execute(gh pr close {1} $REPO_FLAG)+refresh-preview" \ - --bind='alt-a:reload(eval "$FZF_DEFAULT_COMMAND --assignee @me")' \ - --bind='alt-A:reload(eval "$FZF_DEFAULT_COMMAND --author @me")' \ - --bind='alt-s:reload(eval "$FZF_DEFAULT_COMMAND --state all")' \ - --bind='alt-b:reload(eval "$FZF_DEFAULT_COMMAND --head \ - $(git symbolic-ref --short HEAD)")' + --bind 'alt-a:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" + )+change-prompt:'"$pr_prompt"' --assignee @me ❱ " || + [[ ! $FZF_QUERY =~ assignee:@me ]] && echo "put( assignee:@me)" + ' \ + --bind 'alt-A:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --author @me\" + )+change-prompt:'"$pr_prompt"' --author @me ❱ " || + [[ ! $FZF_QUERY =~ author:@me ]] && echo "put( author:@me)" + ' \ + --bind 'alt-b:transform: + branch="$(git symbolic-ref --short HEAD)"; + [[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --head $branch\" + )+change-prompt:'"$pr_prompt"' --head $branch ❱ " || + [[ ! $FZF_QUERY =~ head:$branch ]] && echo "put( head:$branch)" + ' \ + --bind 'alt-s:transform:if [[ ! $FZF_BORDER_LABEL =~ gh ]]; then + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --state all\" + )+change-prompt:'"$pr_prompt"' --state all ❱ " + else + [[ ! $FZF_QUERY =~ state:open ]] && act="put( state:open)" + [[ ! $FZF_QUERY =~ state:closed ]] && act="${act:+$act+}put( state:closed)" + echo "$act" + fi' #2}}} } From 3de9126accaecfcb13a28171a5dcca7fb49077a2 Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sat, 13 Jul 2024 17:27:28 -0700 Subject: [PATCH 13/15] refactor!: add fzf version check --- gh-fzf | 81 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/gh-fzf b/gh-fzf index d0f1115..f28a2f6 100755 --- a/gh-fzf +++ b/gh-fzf @@ -30,10 +30,23 @@ set -e GH_FZF_VERSION="v0.13.0" # x-release-please-version -# USAGE INFO AND LOGS {{{1 +FZF_USER_VERSION="$(fzf --version | awk '{print $1}')" + +# USAGE INFO AND INTERNAL FUNCTIONS {{{1 has() { command -v "$1" >/dev/null 2>&1; } +# https://apple.stackexchange.com/a/123408 +version_number() { + echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }' +} + +requires_version() { + if [ "$(version_number "$1")" -gt "$(version_number "$FZF_USER_VERSION")" ]; then + error "the minimum fzf version is $1 (found $FZF_USER_VERSION)" + fi +} + error() { if [ -n "$1" ]; then printf "Error: " >&2 @@ -1077,28 +1090,62 @@ find_repo_flag() { # ENTRY FUNCTION {{{2 main() { + requires_version "0.45.0" + command="$1" [ -n "$command" ] && shift || default_cmd find_repo_flag "$@" case $command in - h | -h | help | --help) help_cmd "$@" ;; - i | -i | issue | issues | --issue | --issues) issue_cmd "$@" ;; - p | -p | pr | prs | --pr | --prs) pr_cmd "$@" ;; - r | -r | run | runs | --run | --runs) run_cmd "$@" ;; - repo | repos | --repo | --repos) repo_cmd "$@" ;; - release | releases | --release | --releases) release_cmd "$@" ;; - gist | gists | --gist | --gists) gist_cmd "$@" ;; - workflow | workflows | --workflow | --workflows) workflow_cmd "$@" ;; - label | labels | --label | --labels) label_cmd "$@" ;; - milestone | milestones | --milestone | --milestones) milestone_cmd "$@" ;; - util | utils | --util | --utils) util_cmd "$@" ;; - changelog) gh fzf release --repo benelan/gh-fzf ;; - upgrade) gh extension remove benelan/gh-fzf >/dev/null 2>&1 && - gh extension install benelan/gh-fzf --pin "stable" ;; - v | V | -v | -V | version | --version) printf "%s\n" "$GH_FZF_VERSION" ;; - *) error "invalid command: \"$command\"" ;; + h | -h | help | --help) + help_cmd "$@" + ;; + i | -i | issue | issues | --issue | --issues) + requires_version "0.49.0" + issue_cmd "$@" + ;; + p | -p | pr | prs | --pr | --prs) + requires_version "0.49.0" + pr_cmd "$@" + ;; + r | -r | run | runs | --run | --runs) + run_cmd "$@" + ;; + repo | repos | --repo | --repos) + repo_cmd "$@" + ;; + release | releases | --release | --releases) + release_cmd "$@" + ;; + gist | gists | --gist | --gists) + gist_cmd "$@" + ;; + workflow | workflows | --workflow | --workflows) + workflow_cmd "$@" + ;; + label | labels | --label | --labels) + label_cmd "$@" + ;; + milestone | milestones | --milestone | --milestones) + milestone_cmd "$@" + ;; + util | utils | --util | --utils) + util_cmd "$@" + ;; + changelog) + gh fzf release --repo benelan/gh-fzf + ;; + upgrade) + gh extension remove benelan/gh-fzf >/dev/null 2>&1 && + gh extension install benelan/gh-fzf --pin "stable" + ;; + v | V | -v | -V | version | --version) + printf "%s\n" "$GH_FZF_VERSION" + ;; + *) + error "invalid command: \"$command\"" + ;; esac } #2}}} From 58c04737676c99595d70ca337e3b5cf9986ac65c Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sun, 14 Jul 2024 15:28:59 -0700 Subject: [PATCH 14/15] feat(issue): get milestone filter working with gh search mode --- gh-fzf | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gh-fzf b/gh-fzf index f28a2f6..c884d9d 100755 --- a/gh-fzf +++ b/gh-fzf @@ -264,12 +264,14 @@ $global_binds --bind='alt-M:execute( rm -f "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; gh fzf milestone > "${TMPDIR:-/tmp}/gh-fzf-issue-milestone"; - )+transform-prompt( - echo "'"$issue_prompt"' --milestone \"$(cat "${TMPDIR:-/tmp}/gh-fzf-issue-milestone")\" ❱ " - )+reload( + )+transform: m="$(cat ${TMPDIR:-/tmp}/gh-fzf-issue-milestone)"; - eval "$FZF_DEFAULT_COMMAND${m:+ --milestone \"$m\"}" - )' \ + [[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "reload( + eval \"\$FZF_DEFAULT_COMMAND --milestone '\''$m'\''\" + )+change-prompt:'"$issue_prompt"' --milestone \"$m\" ❱ " || + [[ ! $FZF_QUERY =~ milestone: ]] && echo "put( milestone:\"$m\")" + ' \ --bind 'alt-a:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "reload( eval \"\$FZF_DEFAULT_COMMAND --assignee @me\" From 7c58b21df4a9d4743e468063f3447325aa5522bd Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Sun, 14 Jul 2024 15:47:02 -0700 Subject: [PATCH 15/15] chore: cleanup --- gh-fzf | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gh-fzf b/gh-fzf index c884d9d..f9617cf 100755 --- a/gh-fzf +++ b/gh-fzf @@ -227,7 +227,7 @@ $global_binds # INITIAL STATE {{{2 issue_command="GH_FORCE_TTY=$GH_COLUMNS gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT" - issue_prompt="issues${*:+ $*}" + issue_prompt="issue${*:+ $*}" # FZF COMMAND {{{2 FZF_DEFAULT_COMMAND="$issue_command $*" \ @@ -239,7 +239,7 @@ $global_binds --border-label="[mode: fzf] " \ --border-label-pos=-99999 \ --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ - --bind "change:reload-sync:sleep 0.25; $issue_command $* \${FZF_QUERY:+-S {q}} || true" \ + --bind "change:reload-sync:sleep 0.5; $issue_command $* \${FZF_QUERY:+-S {q}} || true" \ --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-issue-query-fzf; @@ -362,7 +362,7 @@ $global_binds " # INITIAL STATE {{{2 pr_command="GH_FORCE_TTY=$GH_COLUMNS gh pr list $pr_template -L $GH_FZF_DEFAULT_LIMIT" - pr_prompt="prs${*:+ $*}" + pr_prompt="pr${*:+ $*}" # FZF COMMAND {{{2 FZF_DEFAULT_COMMAND="$pr_command $*" \ @@ -374,16 +374,20 @@ $global_binds --border-label="[mode: fzf] " \ --border-label-pos=-99999 \ --bind="start:unbind:change${GH_FZF_HIDE_HINTS:+"+toggle-header"}" \ - --bind "change:reload-sync:sleep 0.25; $pr_command $* \${FZF_QUERY:+-S {q}} || true" \ - --bind 'alt-/:transform:[[ ! $FZF_BORDER_LABEL =~ gh ]] && - echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( - echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-pr-query-fzf; - cat ${TMPDIR:-/tmp}/gh-fzf-pr-query-gh - )+change-prompt('"$pr_prompt"' ❱ )+reload-sync($FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true)" || + --bind "change:reload-sync:sleep 0.5; $pr_command $* \${FZF_QUERY:+-S {q}} || true" \ + --bind 'alt-/:transform: + [[ ! $FZF_BORDER_LABEL =~ gh ]] && + echo "rebind(change)+change-border-label([mode: gh] )+disable-search+transform-query( + echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-pr-query-fzf; + cat ${TMPDIR:-/tmp}/gh-fzf-pr-query-gh + )+change-prompt('"$pr_prompt"' ❱ )+reload-sync( + $FZF_DEFAULT_COMMAND ${FZF_QUERY:+-S {q}} || true + )" || echo "unbind(change)+change-border-label([mode: fzf] )+enable-search+transform-query( echo \{q} > ${TMPDIR:-/tmp}/gh-fzf-pr-query-gh; cat ${TMPDIR:-/tmp}/gh-fzf-pr-query-fzf - )"' \ + )" + ' \ --bind='ctrl-r:change-prompt('"$pr_prompt"' ❱ )+execute-silent( rm -f ${TMPDIR:-/tmp}/gh-fzf-pr-query-* )+clear-query+first+reload(eval "$FZF_DEFAULT_COMMAND")' \