Skip to content

Commit

Permalink
style: improve keybinding code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
benelan committed Mar 7, 2024
1 parent abec1bd commit a6b088b
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions gh-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ FZF_DEFAULT_OPTS='
# --------------------------------------------------------------------- {|}

default_cmd() {
FZF_DEFAULT_COMMAND="printf 'COMMAND\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' issue pr run workflow release label repo gist" \
FZF_DEFAULT_COMMAND="printf 'COMMAND\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n' \
issue pr run workflow release label repo gist" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh help {}' \
--preview-window='right:75%,wrap' \
Expand Down Expand Up @@ -189,7 +190,9 @@ Filters > (alt-a: assignee) (alt-A: author) (alt-m: mention) (alt-s: state=all)
--header="$issue_header" \
--bind="start:$on_start" \
--bind="ctrl-o:execute-silent(gh issue view --web {1} $repo_flag)" \
--bind="ctrl-y:execute-silent(gh issue view {1} --json 'url' -q '.url' $repo_flag | $GH_FZF_COPY_CMD)" \
--bind="ctrl-y:execute-silent(
gh issue view {1} --json 'url' -q '.url' $repo_flag | $GH_FZF_COPY_CMD
)" \
--bind="enter:execute(gh issue edit {1} $repo_flag)" \
--bind="alt-o:execute(gh issue develop --checkout {1} $repo_flag)+abort" \
--bind="alt-c:execute(gh issue comment {1} $repo_flag)" \
Expand Down Expand Up @@ -256,7 +259,9 @@ Filters > (alt-a: assignee) (alt-A: author) (alt-b: branch) (alt-s: state=all)
--header="$pr_header" \
--bind="start:$on_start" \
--bind="ctrl-o:execute-silent(gh pr view --web {1} $repo_flag)" \
--bind="ctrl-y:execute-silent(gh pr view {1} --json 'url' -q '.url' $repo_flag | $GH_FZF_COPY_CMD)" \
--bind="ctrl-y:execute-silent(
gh pr view {1} --json 'url' -q '.url' $repo_flag | $GH_FZF_COPY_CMD
)" \
--bind="enter:execute(gh pr edit {1} $repo_flag)" \
--bind="alt-c:execute(gh pr comment {1} $repo_flag)" \
--bind="alt-d:execute(gh pr diff {1} $repo_flag)" \
Expand Down Expand Up @@ -339,7 +344,9 @@ Filters > (alt-f: failed runs) (alt-b: current branch) (alt-u: current user)
--header="$run_header" \
--bind="start:$on_start" \
--bind="ctrl-o:execute-silent(gh run view --web {-1} $repo_flag)" \
--bind="ctrl-y:execute-silent(gh run view {-1} --json 'url' -q '.url' $repo_flag | $GH_FZF_COPY_CMD)" \
--bind="ctrl-y:execute-silent(
gh run view {-1} --json 'url' -q '.url' $repo_flag | $GH_FZF_COPY_CMD
)" \
--bind="enter:execute(gh run watch {-1} $repo_flag)" \
--bind="alt-l:execute(gh run view --log {-1} $repo_flag)" \
--bind="alt-r:execute(gh run rerun {-1} $repo_flag)" \
Expand All @@ -348,11 +355,13 @@ Filters > (alt-f: failed runs) (alt-b: current branch) (alt-u: current user)
--bind='alt-p:execute<gh fzf pr --head $(
gh run view {-1} --json headBranch --jq .headBranch '"$repo_flag"'
) '"$repo_flag"'>' \
--bind='alt-b:reload(eval "$FZF_DEFAULT_COMMAND --branch $(
git symbolic-ref --short HEAD
)")' \
--bind='alt-b:reload(
eval "$FZF_DEFAULT_COMMAND --branch $(git symbolic-ref --short HEAD)"
)' \
--bind='alt-f:reload(eval "$FZF_DEFAULT_COMMAND --status failure")' \
--bind='alt-u:reload(eval "$FZF_DEFAULT_COMMAND --user $(gh api user -q .login)")'
--bind='alt-u:reload(
eval "$FZF_DEFAULT_COMMAND --user $(gh api user -q .login)"
)'
}

# --------------------------------------------------------------------- }}}
Expand Down Expand Up @@ -399,7 +408,9 @@ Filters > (alt-c: private) (alt-o: public) (alt-s: source) (alt-f: forks)
--header-lines=4 \
--bind="start:$on_start" \
--bind='ctrl-o:execute-silent(gh repo view --web {1})' \
--bind="ctrl-y:execute-silent(gh repo view {1} --json 'url' -q '.url' | $GH_FZF_COPY_CMD)" \
--bind="ctrl-y:execute-silent(
gh repo view {1} --json 'url' -q '.url' | $GH_FZF_COPY_CMD
)" \
--bind="alt-p:execute(gh fzf pr --repo {1})" \
--bind="alt-i:execute(gh fzf issue --repo {1})" \
--bind="alt-r:execute(gh fzf run --repo {1})" \
Expand Down Expand Up @@ -464,7 +475,9 @@ Filters > (alt-s: stable) (alt-p: published) (alt-a: ascending)
--header="$release_header" \
--bind="start:$on_start" \
--bind='ctrl-o:execute-silent(gh release view --web {1})' \
--bind="ctrl-y:execute-silent(gh release view {1} --json 'url' -q '.url' | $GH_FZF_COPY_CMD)" \
--bind="ctrl-y:execute-silent(
gh release view {1} --json 'url' -q '.url' | $GH_FZF_COPY_CMD
)" \
--bind="alt-enter:execute(gh release download {1})" \
--bind="alt-X:execute(gh release delete {1})" \
--bind='alt-s:reload(eval "$FZF_DEFAULT_COMMAND --exclude-pre-releases")' \
Expand All @@ -489,7 +502,9 @@ Filters > (alt-p: public) (alt-s: secret)
--header="$gist_header" \
--bind="start:$on_start" \
--bind='ctrl-o:execute-silent(gh gist view --web {1})' \
--bind="ctrl-y:execute-silent(echo https://gist.github.com/$(gh api user -q .login)/{1} | $GH_FZF_COPY_CMD)" \
--bind="ctrl-y:execute-silent(
echo https://gist.github.com/$(gh api user -q .login)/{1} | $GH_FZF_COPY_CMD
)" \
--bind='enter:execute(gh gist edit {1})' \
--bind='alt-c:execute(gh gist clone {1})' \
--bind="alt-X:execute(gh gist delete {1})" \
Expand Down

0 comments on commit a6b088b

Please sign in to comment.