ros2cli icon indicating copy to clipboard operation
ros2cli copied to clipboard

feat: fzf inline editing completion

Open ArkhamKnight25 opened this issue 9 months ago • 1 comments

@fujitatomoya san, Please review the changes. Thank you.

Description

Added shell scripts (Bash + Zsh) that lets us pick topics, services and nodes with fzf, then drop us back on the command line so we can add flags before running. If you cancel fzf, it falls back to ros2cli's default picker. Should I keep this fallback or remove it?

Fixes #1184

Is this user-facing behavior change?

Yes, now we can easily hit up and down arrow keys to get the executed commands from the terminal.

Please let me know of any changes that are needed. It was interesting to learn about cli workflows. Thanks.

ArkhamKnight25 avatar Feb 17 '26 10:02 ArkhamKnight25

@fujitatomoya Thank you for reviewing it. Okay so after hitting enter on ros2 topic echo, and then again selecting the method, to add the additional arguments, Im thinking of fixing this with some python side changes then, the idea is to add an interactive_select_with_edit() helper in helpers.py. After the fzf selection, it would show a readline prompt pre-filled with the selected topic. The user could then type extra flags and hit enter, or just hit enter to run it.

So the flow would look something like this:

amrit@system25:~/ros2_ws$ ros2 topic echo
Select topic to echo:
> /chatter

And once the user selects it, it would look like this:

amrit@system25:~/ros2_ws$ ros2 topic echo
ros2 topic echo > /chatter <args>

Or

can make it look better with just

amrit@system25:~/ros2_ws$ ros2 topic echo
> /chatter <args>

User can type the additional arguments afterros2 topic echo > /chatteror > /chatter and hit enter to execute.

Then I’d update the five topic verbs (echo, info, hz, bw, type). Each verb would store a reference to its parser in add_arguments() using self._parser = parser, use the new helper instead of interactive_select, and then reparse the user input with self._parser.parse_args(tokens, namespace=args) so that any extra flags get handled exactly the same way as if they were typed on the original command line.

And

  • This will solve the problem of adding the arguments in the interactive, but the shell still will record only the ros2 topic echo in the history. How should I approach it?
  • Is storing self._parser = parser in add_arguments() okay? and using shlex.split() to tokenize the user input before re-parsing?

I did think of this approach earlier, but it won't store it in the history, so dropped the idea.

happy to adjust based on feedback.

ArkhamKnight25 avatar Feb 19 '26 03:02 ArkhamKnight25