diff --git a/gh-notify b/gh-notify
index 9b85a1c..9b0ff20 100755
--- a/gh-notify
+++ b/gh-notify
@@ -22,6 +22,22 @@ export GH_REST_API_VERSION="X-GitHub-Api-Version:2022-11-28"
# Enable terminal-style output even when the output is redirected.
export GH_FORCE_TTY=1
+# Need to be exported because of its use in the 'print_help_text' function
+set -o allexport
+# Customize the fzf keys using environment variables
+: "${GH_NOTIFY_MARK_ALL_READ_KEY:=ctrl-a}"
+: "${GH_NOTIFY_OPEN_BROWSER_KEY:=ctrl-b}"
+: "${GH_NOTIFY_VIEW_DIFF_KEY:=ctrl-d}"
+: "${GH_NOTIFY_VIEW_PATCH_KEY:=ctrl-p}"
+: "${GH_NOTIFY_RELOAD_KEY:=ctrl-r}"
+: "${GH_NOTIFY_MARK_READ_KEY:=ctrl-t}"
+: "${GH_NOTIFY_COMMENT_KEY:=ctrl-x}"
+: "${GH_NOTIFY_RESIZE_PREVIEW_KEY:=btab}"
+: "${GH_NOTIFY_VIEW_KEY:=enter}"
+: "${GH_NOTIFY_TOGGLE_PREVIEW_KEY:=tab}"
+: "${GH_NOTIFY_TOGGLE_HELP_KEY:=?}"
+set +o allexport
+
# The maximum number of notifications per page (set by GitHub)
export GH_NOTIFY_PER_PAGE_LIMIT=50
# Assign 'GH_NOTIFY_DEBUG_MODE' with 'true' to see more information
@@ -111,18 +127,18 @@ ${WHITE_BOLD}Flags${NC}
${GREEN}-w ${NC} display the preview window in interactive mode
${WHITE_BOLD}Key Bindings fzf${NC}
- ${GREEN}? ${NC} toggle help
- ${GREEN}enter ${NC} view the selected notification in the 'less' pager
- ${GREEN}tab ${NC} toggle notification preview
- ${GREEN}shift+tab${NC} resize the preview window
+ ${GREEN}${GH_NOTIFY_TOGGLE_HELP_KEY} ${NC} toggle help
+ ${GREEN}${GH_NOTIFY_VIEW_KEY} ${NC} view the selected notification in the 'less' pager
+ ${GREEN}${GH_NOTIFY_TOGGLE_PREVIEW_KEY} ${NC} toggle notification preview
+ ${GREEN}${GH_NOTIFY_RESIZE_PREVIEW_KEY}${NC} resize the preview window
${GREEN}shift+↑↓ ${NC} scroll the preview up/ down
- ${GREEN}ctrl+a ${NC} mark all displayed notifications as read and reload
- ${GREEN}ctrl+b ${NC} browser
- ${GREEN}ctrl+d ${NC} view diff
- ${GREEN}ctrl+p ${NC} view diff in patch format
- ${GREEN}ctrl+r ${NC} reload
- ${GREEN}ctrl+t ${NC} mark the selected notification as read and reload
- ${GREEN}ctrl+x ${NC} write a comment with the editor and quit
+ ${GREEN}${GH_NOTIFY_MARK_ALL_READ_KEY} ${NC} mark all displayed notifications as read and reload
+ ${GREEN}${GH_NOTIFY_OPEN_BROWSER_KEY} ${NC} browser
+ ${GREEN}${GH_NOTIFY_VIEW_DIFF_KEY} ${NC} view diff
+ ${GREEN}${GH_NOTIFY_VIEW_PATCH_KEY} ${NC} view diff in patch format
+ ${GREEN}${GH_NOTIFY_RELOAD_KEY} ${NC} reload
+ ${GREEN}${GH_NOTIFY_MARK_READ_KEY} ${NC} mark the selected notification as read and reload
+ ${GREEN}${GH_NOTIFY_COMMENT_KEY} ${NC} write a comment with the editor and quit
${GREEN}esc ${NC} quit
${WHITE_BOLD}Table Format${NC}
@@ -481,24 +497,24 @@ select_notif() {
output=$(
SHELL="$(which bash)" command fzf \
--ansi \
- --bind "btab:change-preview-window(75%:nohidden|75%:down:nohidden:border-top|nohidden)" \
+ --bind "${GH_NOTIFY_RESIZE_PREVIEW_KEY}:change-preview-window(75%:nohidden|75%:down:nohidden:border-top|nohidden)" \
--bind "change:first" \
- --bind "ctrl-a:execute-silent(mark_all_read {})+reload:print_notifs || true" \
- --bind "ctrl-b:execute-silent:open_in_browser {}" \
- --bind "ctrl-d:toggle-preview+change-preview:if command grep -q PullRequest <<<{10}; then command gh pr diff {11} --repo {5} | highlight_output; else view_notification {}; fi" \
- --bind "ctrl-p:toggle-preview+change-preview:if command grep -q PullRequest <<<{10}; then command gh pr diff {11} --patch --repo {5} | highlight_output; else view_notification {}; fi" \
- --bind "ctrl-r:reload:print_notifs || true" \
- --bind "ctrl-t:execute-silent(mark_individual_read {})+reload:print_notifs || true" \
- --bind "enter:execute:view_notification --all_comments {} | less ${less_args[*]} >/dev/tty" \
- --bind "tab:toggle-preview+change-preview:view_notification {}" \
- --bind "?:toggle-preview+change-preview:print_help_text" \
+ --bind "${GH_NOTIFY_MARK_ALL_READ_KEY}:execute-silent(mark_all_read {})+reload:print_notifs || true" \
+ --bind "${GH_NOTIFY_OPEN_BROWSER_KEY}:execute-silent:open_in_browser {}" \
+ --bind "${GH_NOTIFY_VIEW_DIFF_KEY}:toggle-preview+change-preview:if command grep -q PullRequest <<<{10}; then command gh pr diff {11} --repo {5} | highlight_output; else view_notification {}; fi" \
+ --bind "${GH_NOTIFY_VIEW_PATCH_KEY}:toggle-preview+change-preview:if command grep -q PullRequest <<<{10}; then command gh pr diff {11} --patch --repo {5} | highlight_output; else view_notification {}; fi" \
+ --bind "${GH_NOTIFY_RELOAD_KEY}:reload:print_notifs || true" \
+ --bind "${GH_NOTIFY_MARK_READ_KEY}:execute-silent(mark_individual_read {})+reload:print_notifs || true" \
+ --bind "${GH_NOTIFY_VIEW_KEY}:execute:view_notification --all_comments {} | less ${less_args[*]} >/dev/tty" \
+ --bind "${GH_NOTIFY_TOGGLE_PREVIEW_KEY}:toggle-preview+change-preview:view_notification {}" \
+ --bind "${GH_NOTIFY_TOGGLE_HELP_KEY}:toggle-preview+change-preview:print_help_text" \
--border horizontal \
--color "border:dim" \
--color "header:green:italic:dim" \
--color "prompt:80,info:40" \
--delimiter '\s+' \
- --expect "esc,ctrl-x" \
- --header "? help · esc quit" \
+ --expect "esc,${GH_NOTIFY_COMMENT_KEY}" \
+ --header "${GH_NOTIFY_TOGGLE_HELP_KEY} help · esc quit" \
--info=inline \
--no-multi \
--pointer="▶" \
@@ -522,7 +538,7 @@ select_notif() {
# quit with exit code 0; 'fzf' returns 130 by default
exit 0
;;
- ctrl-x)
+ "${GH_NOTIFY_COMMENT_KEY}")
if command grep -qE "Issue|PullRequest" <<<"$type"; then
command gh issue comment "$num" --repo "$repo_full_name"
mark_individual_read "$selected_line" || die "Failed to mark the notification as read."
diff --git a/readme.md b/readme.md
index ece8b3d..679424c 100644
--- a/readme.md
+++ b/readme.md
@@ -48,21 +48,21 @@ gh notify [Flags]
### Key Bindings fzf
-| Keys | Description |
-| ------------------------------ | --------------------------------------------------- |
-| ? | toggle help |
-| enter | view the selected notification in the 'less' pager |
-| tab | toggle notification preview |
-| shifttab | resize the preview window |
-| shift↑↓ | scroll the preview up/ down |
-| ctrla | mark all displayed notifications as read and reload |
-| ctrlb | browser |
-| ctrld | view diff |
-| ctrlp | view diff in patch format |
-| ctrlr | reload |
-| ctrlt | mark the selected notification as read and reload |
-| ctrlx | write a comment with the editor and quit |
-| esc | quit |
+| Keys | Description | Customization Environment Variable |
+| ------------------------------ | --------------------------------------------------- | ---------------------------------- |
+| ? | toggle help | `GH_NOTIFY_TOGGLE_HELP_KEY` |
+| enter | view the selected notification in the 'less' pager | `GH_NOTIFY_VIEW_KEY` |
+| tab | toggle notification preview | `GH_NOTIFY_TOGGLE_PREVIEW_KEY` |
+| shifttab | resize the preview window | `GH_NOTIFY_RESIZE_PREVIEW_KEY` |
+| shift↑↓ | scroll the preview up/ down | |
+| ctrla | mark all displayed notifications as read and reload | `GH_NOTIFY_MARK_ALL_READ_KEY` |
+| ctrlb | browser | `GH_NOTIFY_OPEN_BROWSER_KEY` |
+| ctrld | view diff | `GH_NOTIFY_VIEW_DIFF_KEY` |
+| ctrlp | view diff in patch format | `GH_NOTIFY_VIEW_PATCH_KEY` |
+| ctrlr | reload | `GH_NOTIFY_RELOAD_KEY` |
+| ctrlt | mark the selected notification as read and reload | `GH_NOTIFY_MARK_READ_KEY` |
+| ctrlx | write a comment with the editor and quit | `GH_NOTIFY_COMMENT_KEY` |
+| esc | quit | |
### Table Format
@@ -100,6 +100,19 @@ export FZF_DEFAULT_OPTS="
--bind 'ctrl-w:preview-half-page-up,ctrl-s:preview-half-page-down'"
```
+You can also customize the keybindings created by this extension to avoid conflicts with
+the ones defined by `fzf`. For example, change `ctrl-p` to `ctrl-u`:
+
+```sh
+GH_NOTIFY_VIEW_PATCH_KEY="ctrl-u" gh notify
+```
+
+**NOTE:** The assigned key must be a valid key listed in the `fzf` man page:
+
+```sh
+man --pager='less -p "^\s+AVAILABLE_KEYS"' fzf
+```
+
### GitHub Command Line Tool (gh)
In the `gh` tool's config file, you can specify your preferred editor. This is particularly useful
when you use the ctrlx hotkey to comment on a notification.