Jupyter Bonus#
To save you some typing, you may create aliases (to the long commands you issue) to launch Jupyter Notebook by just typing the aliases:
pyd(change directory to the py project directory),venv(activate the virtual environment), andjn(launch Jupyter Notebook) like:
PS C:\Users\[user]> pyd
PS C:\Users\[user]\workspace\py> venv
(.venv) PS C:\Users\[user]\workspace\py> jn
[I 2025-09-07 16:35:42.748 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-09-07 16:35:42.757 ServerApp] jupyter_server_terminals | extension was successfully linked.
...
...
Windows#
To add aliases in Windows, you modify the user profile. To check whether you have a profile defined already, do the following in PowerShell:
PS C:\Users\[user]> echo $PROFILE
C:\Users\[user]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
echo means print in the terminal, and $PROFILE is a variable that points to the profile script file that runs every time you open a PowerShell session. It’s like a startup configuration file for customizing the environment, setting aliases, defining functions, and loading modules automatically.
You need to edit the profile using Notepad or VS Code. But sometimes the profile .ps1 file and its path do not exist yet, and you will see a “No such file or directory” warning that looks like:
PS /> $Profile
/home/A1653237104/.config/powershell/Microsoft.PowerShell_profile.ps1
PS /> ls /home/A1653237104/.config/powershell/
/usr/bin/ls: cannot access '/home/A1653237104/.config/powershell/': No such file or directory
To create the directories and the .ps1 file, you may use mkdir and touch, or you may run:
New-Item -Path $PROFILE -Force
The following command will open (or create if not exist) the *.ps1 file in Notepad (code $PROFILE will open it in VS Code):
PS C:\Users\[user]]> notepad $PROFILE
You then:
Copy and paste the ##### venv code ##### code block below into your profile.
Save the profile file and exit Notepad.
Close all terminal sessions and exit PowerShell.
Now, when you reopen PowerShell, the aliases should work.
Some systems have the $PROFILE environment variable defined, but do not have the profile path/folder and the profile file created. In that case, when you do notepad $PROFILE, you are trying to open a file that does not exist yet. You may therefore receive an error message or warning saying that the $PROFILE folder (WindowsPowerShell) or the profile file (Microsoft.PowerShell_profile.ps1) does not exist. If so, create them by doing the following steps:
First, check to see if the profile folder exists. If it does, you will be able to change directory into it (the folder is usually WindowsPowerShell or PowerShell, and it is under the user’s Documents folder):
PS C:\Users\[user]> cd $PROFILE\.. ### **cd** into the folder
PS C:\Users\[user]\Documents\WindowsPowerShell> ### ready to edit profile
If the profile folder (WindowsPowerShell or PowerShell) does not exist, you need to create it:
PS C:\Users\[user]> cd .\Documents\
PS C:\Users\[user]\Documents> mkdir WindowsPowerShell ### or "PowerShell" depends on your system
PS C:\Users\[user]\Documents> cd WindowsPowerShell ### cd into the profile folder
PS C:\Users\[user]\Documents\WindowsPowerShell> ### ready to edit profile
After you are in the profile folder, use Notepad or VSCode to edit or create the profile. The profile (*.ps1) name may be different for different versions of Windows. Use the one you have when doing echo $PROFILE:
PS C:\Users\[user]\Documents\WindowsPowerShell> notepad Microsoft.PowerShell_profile.ps1
Notepad will pop up, and you then copy and paste the ##### venv code ##### code block below to the profile to create the aliases:
########## venv code ############################################################
##### 1. py: change directory to py ######
function CDIntroPY {set-location ~\workspace\py\} ### create the change direcotry function
New-Alias "pyd" CDIntroPY ### create the alias py to the function
##### 2. venv: activate virtual environment #####
New-Alias -Name "venv" -Value .\.venv\Scripts\activate ### activate venv alias
##### 3. jn: start Jupyter notebook ##############
function JupyterNotebook { ### create the "jupyter notebook" function
param(
[string]$notebook = "notebook"
)
jupyter $notebook
}
New-Alias -Name "jn" -Value JupyterNotebook ### alias to run the function
########## end of venv code ######################################################
macOS#
For Mac users, you can add the following lines to your ~/.bashrc or ~/.zshrc file, and you should be able to use the aliases to launch Jupyter Notebook fast after you source the file or open a new shell. To edit the .bashrc file, open the terminal and type code .bashrc or nano .bashrc. VS Code (or nano) will then open the file for you to edit.
alias pyd='cd ~/workspace/py'
alias venv='source .venv/bin/activate'
alias jn='jupyter notebook'