ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to customize setup.bash without directly editing setup.bash

asked 2022-03-06 13:22:20 -0500

HiroIshida gravatar image

updated 2022-03-06 14:53:19 -0500

Say I have ~/my_ws workspace and I have ~/my_ws/devel/setup.bash inside which is automatically created.

I'd like to customize the setup.bash behavioir, more concretely, I'd like to add export PATH=/path/to/somewhere:$PATH line to setup.bash. I want this export only when I use my_ws workspace, so I don't want to add this line to my ~/.bashrc. Also, I don't want to manually edit the setup.bash because it is dirty and leading to bags.

Does anybody have good approach to realize the above need?

edit retag flag offensive close merge delete

Comments

you can try editing the setup.sh file and add whatever you need to add. I did not get what did you mean by without manual editing

aarsh_t gravatar image aarsh_t  ( 2022-03-06 14:17:31 -0500 )edit

1 Answer

Sort by ┬╗ oldest newest most voted
0

answered 2022-03-06 15:21:40 -0500

aarsh_t gravatar image

Hello @HiroIshida ,

I can see 2 solutions here, either you can manually edit your devel/setup.sh file or you can edit your ~/.bashrc by editing something like this.

source_my_ws()
{
source "$HOME"/my_ws/devel/setup.bash
export PATH=/path/to/somewhere:$PATH
}

Now whenever you want to source that workspace, you can just call function source_my_ws from terminal

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-03-06 13:22:20 -0500

Seen: 193 times

Last updated: Mar 06 '22