![]() bashrc (conditionally) source the new script. What I came up with is: invert the logic, and make. bashrc first and aren't going to make a separate script wrapper (to run both in order) and aren't going to just bash -c them both in order (that doesn't work we need -c in order to arrange that, but then we don't get a persistent terminal) - what do we do? My Solution if we aren't going to modify the original (to source. bashrc, and then the original script contents. ![]() That shell needs to, by some method, run. The trick to making the original approach work is that the activate script has to run in the last shell created (however many there happen to be). The second issue isn't addressed at all that way. The first issue can't really be solved by using exec bash -norc, because I want the modifications to PS1 from both places - just in the other order. bashrc gets run again, overriding the setting for PS1 įunction definitions aren't exported, so the new shell simply doesn't have it. While it does properly manage the lifetime of the window, The issues seem to result from start a new shell, even with exec rather than as a command. bashrc.) I also didn't want to write a separate custom rcfile because it doesn't feel scalable now I am making two special files each time I want this kind of wrapper (and I expect to want it for a few other things). (In the more general case, I also want to be able to run the script without reloading. In my case, I really do not want to modify the custom script because it is generated by Python. I managed to solve the problem completely in a different way, with this new understanding. Kamil's answer worked well for me, but it turns out I had some minor additional requirements that I didn't realize until I saw the answer. How can I make this properly transparent? However, PS1 does not get set, the prompt is therefore not modified, and the deactivate command does not become available as it normally would. In my testing, the window stays open and is usable the pwd is set properly and the VIRTUALENV and PATH environment variables are properly modified by the script. It's good enough that I could live with it if I really had to, but I'm really bothered by the shortcomings. ![]() The specific use case is that I want to open a window, start in a particular directory (in my case, a folder on the desktop which holds subdirectories for Python projects I'm working on), and have a Python virtual environment activated (in my case, a common "scratch" venv named SANDBOX located directly in that directory).Īfter much research, I eventually ended up with: #!/bin/bash (This is why I have a question to ask here.) ![]() The commands that have run impact the state of the shell.(This means that anything based on read, xterm -keep etc. After the commands run, the window stays open indefinitely, usable to input more shell commands.(Per documentation, this one must be sourced from Bash.) This causes a terminal window to open, and some commands to run, including another script.(This is intended to select an optional, alternate way of starting up a terminal window so I can not simply edit a. I can double-click an icon on my desktop.I am not especially tied to using a shell script for this purpose, but my requirements are as follows: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |