Zend certified PHP/Magento developer

How can I have a terminal window persist beyond the script it was opened for? (NOT just “keep the window open” or start a new shell)

I am not especially tied to using a shell script for this purpose, but my requirements are as follows:

  • I can double-click an icon on my desktop. (This is intended to select an optional, alternate way of starting up a terminal window; so I can not simply edit a .bashrc, .profile etc.)
  • This causes a terminal window to open, and some commands to run, including another script. (Per documentation, this one must be sourced from Bash.)
  • After the commands run, the window stays open indefinitely, usable to input more shell commands. (This means that anything based on read, xterm -keep etc. is not a solution.)
  • The commands that have run impact the state of the shell. (This is why I have a question to ask here.)

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).

After much research, I eventually ended up with:

#!/bin/bash
cd ~/Desktop/dev
source SANDBOX/bin/activate
exec $SHELL

This is almost right. It’s good enough that I could live with it if I really had to, but I’m really bothered by the shortcomings. 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. However, PS1 does not get set, the prompt is therefore not modified, and the deactivate command does not become available as it normally would.

How can I make this properly transparent?