Skip to content

Commit

Permalink
feat: manually truncate results columns to improve search matches and…
Browse files Browse the repository at this point in the history
… readability

The GitHub CLI automatically truncates the text in columns so everything
fits in the terminal dimensions. This PR increases the max length of
all of the columns. Not everything will fit, but fzf can still match
text that is too wide to display, which will improve results.
  • Loading branch information
benelan committed Dec 28, 2023
1 parent aefb4c6 commit 0f08e40
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions gh-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,16 @@ issue_cmd() {
log "DEBUG " "issue > START"

issue_template='\
--json "number,title,author,assignees,state,milestone,labels,updatedAt,body" \
--json "number,title,author,assignees,state,milestone,labels,updatedAt" \
--template '\''
{{- $headerColor := "blue+b" -}}
{{- tablerow
("ISSUE" | autocolor $headerColor)
("LAST UPDATE" | autocolor $headerColor)
("TITLE" | autocolor $headerColor)
("AUTHOR" | autocolor $headerColor)
("MILESTONE" | autocolor $headerColor)
("LAST UPDATE" | autocolor $headerColor)
("LABELS" | autocolor $headerColor)
("BODY" | autocolor $headerColor)
-}}
{{- range . -}}
Expand All @@ -208,12 +207,11 @@ issue_cmd() {
{{- tablerow
(printf "#%v" .number | autocolor $stateColor)
(.title | autocolor "white+h")
((timeago .updatedAt) | autocolor "white+d")
(truncate 100 (.title | autocolor "white+h"))
(.author.login | autocolor "white+d")
($milestoneTitle | autocolor "white+h")
((timeago .updatedAt) | autocolor "white+d")
(pluck "name" .labels | join ", " | autocolor "white+h")
(.body | autocolor "white+d")
(pluck "name" .labels | join ", " | autocolor "white+d")
-}}
{{- end -}}
'\'''
Expand All @@ -224,7 +222,7 @@ Filters > (alt-a: assignee) (alt-A: author) (alt-m: mention) (alt-s: state=all)
'

FZF_DEFAULT_COMMAND="GH_FORCE_TTY=true gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT $*" \
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=42069 gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview 'GH_FORCE_TTY=true gh issue view {1} --comments' \
--header="$issue_header" \
Expand Down Expand Up @@ -252,17 +250,16 @@ pr_cmd() {
log "DEBUG " "pull request > START"

pr_template='\
--json "number,title,state,headRefName,milestone,updatedAt,labels,body" \
--json "number,title,state,headRefName,milestone,updatedAt,labels" \
--template '\''
{{- $headerColor := "blue+b" -}}
{{- tablerow
("PR" | autocolor $headerColor)
("LAST UPDATE" | autocolor $headerColor)
("TITLE" | autocolor $headerColor)
("BRANCH" | autocolor $headerColor)
("LAST UPDATE" | autocolor $headerColor)
("LABELS" | autocolor $headerColor)
("MILESTONE" | autocolor $headerColor)
("BODY" | autocolor $headerColor)
-}}
{{- range . -}}
Expand All @@ -280,12 +277,11 @@ pr_cmd() {
{{- tablerow
(printf "#%v" .number | autocolor $stateColor)
(.title | autocolor "white+h")
(.headRefName | autocolor "white+d")
((timeago .updatedAt) | autocolor "white+h")
(pluck "name" .labels | join ", " | autocolor "white+d")
($milestoneTitle | autocolor "white+h")
(.body)
((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")
-}}
{{- end -}}
'\'''
Expand All @@ -297,7 +293,7 @@ Filters > (alt-a: assignee) (alt-A: author) (alt-b: branch) (alt-s: state=all)
'

FZF_DEFAULT_COMMAND="GH_FORCE_TTY=true gh pr list $pr_template -L $GH_FZF_DEFAULT_LIMIT $*" \
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=42069 gh pr list $pr_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview 'GH_FORCE_TTY=true gh pr view {1} --comments' \
--header="$pr_header" \
Expand Down Expand Up @@ -336,11 +332,11 @@ run_cmd() {
{{- $headerColor := "blue+b" -}}
{{- tablerow
("STATUS" | autocolor $headerColor)
("LAST UPDATE" | autocolor $headerColor)
("WORKFLOW" | autocolor $headerColor)
("BRANCH" | autocolor $headerColor)
("TITLE" | autocolor $headerColor)
("EVENT" | autocolor $headerColor)
("LAST UPDATE" | autocolor $headerColor)
("ID" | autocolor $headerColor)
-}}
Expand All @@ -362,12 +358,12 @@ run_cmd() {
{{- tablerow
($statusText | autocolor $statusColor)
((timeago .updatedAt) | autocolor "white+d")
(.name | autocolor "white+h")
(.headBranch | autocolor "white+d")
(.displayTitle | autocolor "white+h")
(truncate 60 (.headBranch | autocolor "white+d"))
(truncate 100 (.displayTitle | autocolor "white+h"))
(.event | autocolor "white+d")
((timeago .updatedAt) | autocolor "white+h")
(.databaseId | autocolor "white+d")
(.databaseId | autocolor "white+h")
-}}
{{- end -}}
'\'''
Expand All @@ -378,7 +374,7 @@ Filters > (alt-f: failed runs) (alt-b: current branch) (alt-u: current user)
'

FZF_DEFAULT_COMMAND="GH_FORCE_TTY=true gh run list $run_template -L $GH_FZF_DEFAULT_LIMIT $*" \
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=42069 gh run list $run_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview 'GH_FORCE_TTY=true gh run view {-1}' \
--header="$run_header" \
Expand Down

0 comments on commit 0f08e40

Please sign in to comment.