Create a bluesky IPython profile#

This bash command create a new IPython profile for bluesky:

$ ipython profile create bluesky --ipython-dir="~/.ipython"

Next, create the starter script for this profile. This will ensure that the instrument package gets loaded when starting a bluesky IPython session.

Note

Copy all these lines and paste them exactly into your terminal.

cat > ~/.ipython/profile_bluesky/startup/00-start-bluesky.py  << EOF
import pathlib, sys
sys.path.append(str(pathlib.Path().home() / "bluesky"))
from instrument.collection import *
EOF

To start an IPython session with the new bluesky profile, you can now use the following command:

$ ipython --profile=bluesky
How to create an alias to start a bluesky session? Creating a bash alias is like creating a custom shortcut. You can do this by editing the ~/.bashrc and ~/.bash_aliases files, which are configuration files for your bash shell. Here's a simple step-by-step guide:
  1. Open a terminal.
  2. Open the ~/.bashrc and ~/.bash_aliases files with your prefered text editor, e.g.:
    $  gedit ~/.bashrc ~/.bash_aliases 
    
    If any of those files do not exist, this command will create blank ones.
  3. In ~/.bash_aliases, scroll down to the end of the file or find a suitable place to add your alias. On a new line, type:
    export BLUESKY_CONDA_ENV=bluesky_2023_3
    alias start_bluesky='conda activate ${BLUESKY_CONDA_ENV}; ipython --profile=bluesky'
    
    Note: this lines may already be included in your ~/.bash_aliases, e.g., if you have created an alias to activate the bluesky conda environment.
  4. In ~/.bashrc, scroll down to the end of the file or find a suitable place to add the following lines:
    source ~/.bash_aliases
    
  5. Save your changes.
  6. Type bash and press enter, or open a new terminal windows to make the new alias available.
You can now use the alias start_bluesky to activate the conda environment and and start a new bluesky session in a terminal.

For more info about IPython configuration, see here.