I am working on software at a large corporation where I have little control over the overall technologies used, and as a result need to find solutions that will work within the constraints I have.
What I'm working on: I'm developing a UI that lets users launch konsoles with specific environments based on the projects they are working on. We currently have a command (let's call it "setContext") that users run in their konsole manually with a lot of arguments. setContext does a lot of work and sets a lot of environment variables. As part of my constraints, I have to use konsole, tcsh, and this setContext command. All my UI needs to do is compose the setContext command with the proper arguments, open a konsole, and run that command for the user, after what they will be in control.
The command I generate is something like:
konsole -e tcsh -c "setContext --someArgs"
This works, but closes the konsole right away. Using the --noclose
option when launching the konsole keeps it open but not interactive.
The commonly accepted solution to this problem, is to append ;bash
or ;$SHELL
at the end of the command, in my case I have extrapolated it to be ;tcsh
.
This is what is suggested in the following links, and many others:
- https://askubuntu.com/questions/20330/how-to-run-a-script-without-closing-the-terminal/1209836#1209836
- https://askubuntu.com/questions/46627/how-can-i-make-a-script-that-opens-terminal-windows-and-executes-commands-in-the
- Run commands in a terminal, then let me type more commands
- https://askubuntu.com/questions/484993/run-command-on-anothernew-terminal-window
This nearly works, as it does indeed keep the konsole open. In fact this is what I have been using for weeks without troubles, however we have noticed that running tcsh
after setContext
sources all the initialization files again (~/.cshrc, etc..), which resets some of the variables set by setContext
.
This needs to work for hundreds of users, and I have no control over the cshrc files, so I need to find a way to keep the konsole open without sourcing these again. I tried tcsh -f
but that doesn't preserve the environment.
I have been searching online all afternoon but haven't managed to find a solution. While I understand environments and commands okay, I am no expert and usually work in python. I am resorting to ask here because everything I'm finding is either a re-hash of the answer above, requires to modify cshrc files, or is way above my level and I can't decipher it.
Thanks in advance.