Open muellerbernd opened 1 year ago
Yep, in the shell hook will work nicely. Be aware that argcomplete
was only listed as a ROS 2 CLI dependency fairly recently, so anything older than Humble will need an override to add it.
# Add argcomplete as a propagated ros2cli dependency.
# https://github.com/ros2/ros2cli/pull/564
# https://github.com/ros2/ros2cli/blob/26715cbb0948258d6f04b94c909d035c5130456a/ros2cli/ros2cli/cli.py#L45
ros2cli = rosSuper.ros2cli.overrideAttrs ({ propagatedBuildInputs ? [ ], ... }: {
propagatedBuildInputs = propagatedBuildInputs ++ [ rosSelf.pythonPackages.argcomplete ];
});
and how would I do that? For ros2 I tried to use the following in my setup
shellHook = ''
eval ${pkgs.python310Packages.argcomplete}/bin/register-python-argcomplete ros2
eval ${pkgs.python310Packages.argcomplete}/bin/register-python-argcomplete colcon
eval ${pkgs.python310Packages.argcomplete}/bin/register-python-argcomplete rosidl
'';
That looks good to me. I have a more developed setup here (see the shell hook and setup script): https://github.com/hacker1024/nix-ros-workspace/blob/master/packages/ros/build-ros-workspace/default.nix
Yeah I saw your repo and took inspirations from there for my shell hook. But the autocompletion does not work. When I build my flake, change into it and call the following by hand then autocompletion works.
eval "$(register-python-argcomplete ros2)"
eval "$(register-python-argcomplete colcon)"
eval "$(register-python-argcomplete rosidl)"
But it does not work when I put these commands into my shellHook.
@hacker1024 I got it working using the setup script from your setup. But it only works with bash
when I use zsh
it does not work. Do you have any tips on how to get it working with zsh
?
It works when I call eval "$(mk-workspace-shell-setup)"
after I got into zsh.
It works when I call eval "$(mk-workspace-shell-setup)" after I got into zsh.
That is expected. The shellHook
does not run directly in Zsh, but rather in Bash before launching Zsh. This allows environment variables to be set, but does not allow any shell-specific setup to be done. This means that completion cannot be set up automatically.
I am using this overlay for ros1 and ros2 development. For ros1 autocompletion was enable after sourcing
devel/setup.zsh
. For ros2 someting likeeval "$(register-python-argcomplete colcon)"
would be needed (see this issue). What is the best way to setup autocompletion for ros1 and ros2? Can I setup autocompletion in themkshell
shell-hook?