-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confirm before exit #96
Comments
Excerpt from the # EXIT STATUS
0 Normal exit
1 No match
2 Error
126 Permission denied error from become action
127 Invalid shell command for become action
130 Interrupted with CTRL-C or ESC We could modify the code to allow the ⎋ Escape key to be reassigned to another key combination, such as ⌃ Control + C (expanding #87). diff --git a/gh-notify b/gh-notify
index cb3caff4928a..7b66d28fc8b1 100755
--- a/gh-notify
+++ b/gh-notify
@@ -40,6 +40,7 @@ GH_NOTIFY_PER_PAGE_LIMIT=50
: "${GH_NOTIFY_VIEW_KEY:=enter}"
: "${GH_NOTIFY_TOGGLE_PREVIEW_KEY:=tab}"
: "${GH_NOTIFY_TOGGLE_HELP_KEY:=?}"
+: "${GH_NOTIFY_EXIT_KEY:=esc}"
# Assign 'GH_NOTIFY_DEBUG_MODE' with 'true' to see more information
: "${GH_NOTIFY_DEBUG_MODE:=false}"
@@ -164,7 +165,7 @@ ${WHITE_BOLD}Key Bindings fzf${NC}
${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}${GH_NOTIFY_TOGGLE_KEY} ${NC} toggle the selected notification
- ${GREEN}esc ${NC} quit
+ ${GREEN}${GH_NOTIFY_EXIT_KEY} ${NC} quit
${WHITE_BOLD}Table Format${NC}
${GREEN}unread symbol${NC} indicates unread status
@@ -569,8 +570,8 @@ select_notif() {
--color "header:green:italic:dim" \
--color "prompt:80,info:40" \
--delimiter '\s+' \
- --expect "esc,${GH_NOTIFY_COMMENT_KEY}" \
- --header "${GH_NOTIFY_TOGGLE_HELP_KEY} help · esc quit" \
+ --expect "${GH_NOTIFY_EXIT_KEY},${GH_NOTIFY_COMMENT_KEY}" \
+ --header "${GH_NOTIFY_TOGGLE_HELP_KEY} help · ${GH_NOTIFY_EXIT_KEY} quit" \
--info=inline \
--multi \
--pointer="▶" \
@@ -590,13 +591,13 @@ select_notif() {
# 2nd line: the selected line when the user pressed the key
expected_key="$(command sed q <<<"$output")"
selected_line="$(command sed '1d' <<<"$output")"
- if [[ $(sed -n '$=' <<<"$selected_line") -gt 1 && $expected_key != "esc" ]]; then
+ if [[ $(sed -n '$=' <<<"$selected_line") -gt 1 && $expected_key != "${GH_NOTIFY_EXIT_KEY}" ]]; then
die "Please select only one notification for this operation."
fi
IFS=' ' read -r _ thread_id thread_state _ repo_full_name _ _ _ _ type num _ <<<"$selected_line"
[[ -z $type ]] && exit 0
case "$expected_key" in
- esc)
+ "${GH_NOTIFY_EXIT_KEY}")
# quit with exit code 0; 'fzf' returns 130 by default
exit 0
;; Coupled with the GH_NOTIFY_FZF_OPTS="--bind 'esc:ignore'" GH_NOTIFY_EXIT_KEY="ctrl-c" gh notify -an 20 |
Could you check out #98 and see if the behavior is acceptable? GH_NOTIFY_FZF_OPTS="--bind 'esc:ignore'" GH_NOTIFY_EXIT_KEY="ctrl-c" gh notify -an 20 |
It is too easy to hit the
ESC
key and then have to wait to load all the notifications again.Would it be possible to add a confirmation before escaping (where hitting escape again will cancel the exit)?
The text was updated successfully, but these errors were encountered: