fatalaccidents
fatalaccidents

Reputation: 192

Symbolically linking files inside a git subdirectory

I have a question regarding git. I may be completely off base here with how I'm even approaching the questions, so I would be glad to hear a completely differing opinion of how to get this done.

I keep a handful of python and bash scripts in a folder I upkeep called utils. It has folders inside it, such as mesh_tools with various python files inside that do random esoteric jobs. As it is getting larger and I'm switching computers, I'm wishing that I didn't have to manually go in and symbolically link all of these files into a /usr/local/bin or somewhere else in my path.

Is there a way to recursively symbolically link files (and is this even a good idea) or create a PATH that recursively looks through? Or am I just simply going about this in the completely wrong way? Any opinions or suggestions would be greatly appreciated.

Upvotes: 2

Views: 48

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80931

You just want all of the binaries/etc. in those directories to be available as commands automatically?

Assuming there aren't other non-binary files in those directories you can just add all those directories to your PATH directly.

Just add something like this (untested) to your shell startup scripts.

while IFS= read -r -d '' dir; do
    PATH="$PATH:$dir"
done < <(find toplevel -type d -print0)

If that isn't the case you could always write an install script or make target that symlinks all the binaries into a target directory and then just put that directory in the PATH. You can then run that script as many times as you like and it will add any new links as necessary. (Writing it so that it removes old links would be nifty and/or have it assume full control of the directory and just swap it out with an entirely new one.)

Upvotes: 2

Related Questions