Multiplexing TTL serial lines with transistors
What you want is a digital multiplexer, in this case a 74LS157. The following schematic should give you an idea of how it would work. This would take 3/4 of a single chip.







simulate this circuit &ndash; Schematic created using CircuitLab

In this case, a single bit is used to determine which slave link is active - 0 for Slave 1 and 1 for Slave 2. The only possible change you would need is (perhaps), to set the unused TX multiplexer channels to 1 instead of 0.

With readily available chips, you can increase the number of channels in powers of two up to 8 or 16 easily, but in principle can extend the scheme indefinitely.