Robotics StackExchange | Archived questions

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

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?

Asked by HiroIshida on 2022-03-06 14:22:20 UTC

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

Asked by aarsh_t on 2022-03-06 15:17:31 UTC

Answers

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

Asked by aarsh_t on 2022-03-06 16:21:40 UTC

Comments