Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lint shell scripts
run: find . -name '*.sh' -not -path '*/.*' | xargs shellcheck --severity=warning
- name: Checkout code
uses: actions/checkout@v4
- name: Lint shell scripts
run: find . -name '*.sh' -not -path '*/.*' | xargs shellcheck --severity=warning
671 changes: 671 additions & 0 deletions README.md

Large diffs are not rendered by default.

39 changes: 24 additions & 15 deletions ax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -559,29 +559,35 @@ prompt_git_sync() {
tput sc 2>/dev/null
_draw_prompt "$selected"

# Save terminal state — read -rs modifies stty settings; must restore on exit
local stty_save
stty_save=$(stty -g 2>/dev/null)

# Drain any stray bytes left in stdin by the loader before reading input
while IFS= read -rsn1 -t 0 _discard 2>/dev/null; do :; done

# Event loop — reads escape sequences (arrows) and plain chars
while true; do
local key seq

# Read first byte — detects start of any keypress
IFS= read -rsn1 key

# Arrow keys send ESC [ A/Bconsume remaining 2 bytes if ESC detected
# Arrow keys send ESC [ C/Dread both remaining bytes in one call
if [[ "$key" == $'\033' ]]; then
IFS= read -rsn1 -t 0.05 seq
if [[ "$seq" == '[' ]]; then
IFS= read -rsn1 -t 0.05 key
case "$key" in
A|D) # Up / Left arrow → YES
selected=0 ;;
B|C) # Down / Right arrow → NO
selected=1 ;;
esac
# Restore saved position and redraw after every navigation event
tput rc 2>/dev/null
_draw_prompt "$selected"
continue
fi
IFS= read -rsn2 -t 0.15 seq || true
case "$seq" in
'[D') # Left arrow → YES
selected=0
tput rc 2>/dev/null
_draw_prompt "$selected"
continue ;;
'[C') # Right arrow → NO
selected=1
tput rc 2>/dev/null
_draw_prompt "$selected"
continue ;;
esac
# Lone ESC treated as cancel → NO
selected=1
break
Expand All @@ -595,6 +601,9 @@ prompt_git_sync() {
esac
done

# Restore terminal state — undo any stty changes made by read -rs
stty "$stty_save" 2>/dev/null

# Wipe the prompt panel then restore cursor to panel origin
tput rc 2>/dev/null
for ((i=0; i<PROMPT_LINES; i++)); do printf "\033[2K\n"; done
Expand Down
Loading