UoE BSc Computer Science First-class Honours --> Imperial MSc Advanced Comput'ing
Use echo $PROFILE
to check which profile.ps1
file your Windows Terminal is using.
. $PROFILE
to apply your changes like source ~/.bashrc
, or restart the terminal.export xxx=xxxxxx
): Set-Variable -Name “xxx” -Value “xxxxxxx” -Option Constant
$xxx
.$xxx = xxxxxx
.alias f="xxxx"
): function f { xxxx }
function proj {
param (
[string]$projName,
[switch]$vscode,
[switch]$explorer
)
if ($projName) {
$projPath = Join-Path -Path $funpy -ChildPath $projName
if (Test-Path $projPath) {
Set-Location $projPath
if ($explorer) {
explorer.exe .
}
if ($vscode -or -not $explorer) {
code .
}
} else {
Write-Error "The project '$projName' does not exist."
}
} else {
Get-ChildItem -Path $funpy -Directory | ForEach-Object { $_.Name }
}
}
https://stackoverflow.com/questions/15694338/how-to-get-a-list-of-custom-powershell-functions:
# get custom functions
$sysfunctions = Get-ChildItem function:
function custom {Get-ChildItem function: | Where-Object {$sysfunctions -notcontains $_} }
profile.ps1
document, such as readme.md
.Write the following simple streamlit webpage to read and display the markdown.
import streamlit as st
import os
import subprocess
# Set the page configuration to use the wide layout
st.set_page_config(layout="centered")
# Retrieve the profilePath variable from PowerShell
# Make sure you have defined the profilePath variable in your environment or profile.ps1, which is the folder where your $PROFILE resides.
profile_path = subprocess.check_output(['powershell', '-Command', '(Get-Variable -Name profilePath).Value'], text=True).strip()
doc_path = os.path.join(profile_path, 'readme.md')
with open(doc_path, 'r', encoding='utf-8') as file:
readme_content = file.read()
st.markdown(readme_content)
Also, define a simple function to replace manual commands.
function doc {
$doc_py_path = Join-Path -Path $profilePath -ChildPath "doc.py"
streamlit run $doc_py_path
}
doc
in the command line to get: