As an alternative, use `ctrl`+`f` for "forward-inc-search"; it's easier to remember (mnemonic) and means you can still use `ctrl`+`s` or `ctrl`+`q` for flow control as normal. For example, in Bash:

    bind '"\C-f": forward-search-history'

    # bash: a small cantrip to disable ixon before readline and
    # turning it on again afterwards during command execution
    # (assuming trap DEBUG not in use)
    #
    # inspired by and to extend the article on ixon on
    # susam.net/blog/from-xon-xoff-to-forward-incremental-search.html

    unset _IXON
    # before readline, issue stty -ixon to permit use of ^s for
    # incremental search, then reenable it for the next command
    PROMPT_COMMAND="$PROMPT_COMMAND; : _IXONOFF"
    function _TRAP_DEBUG {
       if [ "$BASH_COMMAND" = ": _IXONOFF" ]; then
          # about to enter readline, thus turn off ixon
          stty -ixon
          # and reenable it for the command from readline
          _IXON=1
       elif [ "$_IXON" = "1" ]; then
          # readline finished, we are about to run its input as command
          stty ixon
          unset _IXON
       fi
    }
    trap _TRAP_DEBUG DEBUG

    echo "test it by ^s/^q the output during the run of the next command"
    echo "(use ^c to end)"
    find / -xdev 2>/dev/null

    echo test ^s incremental search during readline:
    : ...

    : enjoy,
    : Peter

With respect to the cantrip, the below line in `~/.inputrc` might be preferable, as it remaps (forward) i-search to `ctrl`+`^` for all programs using GNU-readline.

    "\C-^": forward-search-history

And if you edit `~/.inputrc`, consider adding a mapping for `kill-region`, in my case using an en-US keymap, its `esc` `ctrl`+`@`, and permits to move/copy/erase character regions together with `ctrl`+`y` and `ctrl`+`x` `ctrl`+`x`.

    "\e\C-@": kill-region

'nough said,
Peter

Thank you, Peter, for your comments. It took a few changes to get your Bash script to work properly in my shell. Since I do not have `PROMPT_COMMAND` set in my shell, the evaluation of the following prompt command

    PROMPT_COMMAND="$PROMPT_COMMAND; : _IXONOFF"

was causing this error:

    bash: PROMPT_COMMAND: line 0: syntax error near unexpected token `;'
    bash: PROMPT_COMMAND: line 0: `; : _IXONOFF'

Here is how I modified your script to check if `PROMPT_COMMAND` is set before expanding it. If it is not set we use the null command `:` before the semicolon separator.

    unset _IXON
    PROMPT_COMMAND="${PROMPT_COMMAND:-:}; : _IXONOFF"
    function _TRAP_DEBUG {
       if [ "$BASH_COMMAND" = ": _IXONOFF" ]; then
          stty -ixon
          _IXON=1
       elif [ "$_IXON" = "1" ]; then
          stty ixon
          unset _IXON
       fi
    }
    trap _TRAP_DEBUG DEBUG

To test this, we can add the above script to `~/.bashrc`, then run something like `ping localhost` and confirm that `ctrl`+`s` pauses the output, whereas in the shell `ctrl`+`s` performs forward incremental search.

This was a very interesting read! I have personally solved this by using fuzzy finder, which gives a menu/search box with a selection instead of the simplistic string matching of `ctrl`+`r`.

If you are a heavy terminal user, I would recommend looking into https://wiki.archlinux.org/title/fzf. I see the built-in search being especially useful on remote/shared machines, where you do not necessarily want to install stuff.

The XON/XOFF feature actually seems quite useful for terminals without scrollback. Or for when you don't have a mouse. Hopefully I'll remember it. Thank you very much for your article!

This is a great explanation, especially the part describing how control codes are mapped to their corresponding letters. I always felt there was probably some logic to it, but the idea never fully materialized into something I thought to investigate. Learning about how to disable XON/OFF is more like a bonus.