Ah, I would suggest that you should not use symlinks. Instead, you should use environment variables. I’ll offer an example. I use this myself, but have never made it public, so …YMMV: GitHub - chetmurthy/Sandboxes: Perl tool for dealing with many Sandboxes
The idea here is: I have a bunch of “sandboxes”. A sandbox is defined by a directory, and then a bunch of environment variables that get set or updated. So I can add to PATH, set OCAMLPATH, etc. This happens in bashrc scripts. So the sandbox fzf
is defined (in rc.yaml
):
fzf:
directory: '$HOME/Hack/FZF'
rc: '$HOME/Hack/FZF/dot.bashrc'
varname: FZFROOT
which tells you an rcfile to source before firing up whatever program you want to run in it. And the sandbox Opam
is:
Opam:
directory: '$HOME/Hack/Opam-2.1.2/GENERIC'
rc:
- '$HOME/.sandbox/bashrc/aliases.bashrc'
- '$HOME/Hack/Opam-2.1.2/GENERIC/dot.bashrc'
- '$HOME/.sandbox/bashrc/ocaml-base.bashrc'
varname: CAMLROOT
description: "Opam 2.1.2 installation"
So now I can do:
$ RUN -s fzf,Opam bash
and that’ll run the scripts for these two sandboxes, and then fire up an interactive shell. So I can have a ton of such sandboxes. I also have “composite” sandboxes, e.g.:
OCaml:
- fzf
- Opam
- OCaml-Python-VENV
so RUN -s OCaml bash
will run the scripts for all three of these, in order.
Anyway, I find that this is a pretty convenient way to manage a large number of somewhat-related environments, without the danger of somehow mixing them up in untoward ways.
The RUN
script also sets the prompt and some magic string that gets blurted by bash
to set the title-bar of the window in x-windows and Chromeos, so I can see what the current sandbox (or sequence of sandboxes) is in the titlebar.
ETA: of course, if I enter a sandbox, viz.
$ RUN -s fzf bash
then in that interactive shell I can enter another, viz.
$ RUN -s Opam bash
and that will be the same as if I did
$ RUN -s fzf,Opam bash