tmux-grab: filter control chars out of candidates
capture-pane occasionally leaves raw control bytes (stray escape-
sequence remnants, bells) embedded in a token or joined run. Dropping
any candidate that contains one keeps the fzf list to text worth
copying or sending to the pane.
Assisted-by: Claude Sonnet 5 via Claude Code
diff --git a/bin/,tmux-grab b/bin/,tmux-grab
index 0ed10e75..f91d6427 100755
--- a/bin/,tmux-grab
+++ b/bin/,tmux-grab
@@ -118,7 +118,9 @@ main() {
# parenthesized spans with the parens stripped (so "(utils.rb:42)"
# yields "utils.rb:42", and a parenthetical phrase survives as one
# candidate instead of shattering at its inner spaces); then
- # punctuation-split sub-tokens (so "foo", "bar", "baz" are too).
+ # punctuation-split sub-tokens (so "foo", "bar", "baz" are too). A final
+ # filter drops any candidate carrying a raw control byte -- stray escape-
+ # sequence remnants, bells, and the like -- so only real text reaches fzf.
local tokens
tokens=$(
{
@@ -132,7 +134,7 @@ main() {
}
}'
printf '%s\n' "$pane_text_reversed" | grep --only-matching --extended-regexp '[[:alnum:]_]+' || true
- } | awk '!seen[$0]++'
+ } | awk '!seen[$0]++' | grep -Ev '[[:cntrl:]]' || true
)
[[ -n "$tokens" ]] || exit 0