Skip to content

Instantly share code, notes, and snippets.

@wyattferguson
Last active March 13, 2026 20:11
Show Gist options
  • Select an option

  • Save wyattferguson/c03bceec446e90814de474dfb20ad651 to your computer and use it in GitHub Desktop.

Select an option

Save wyattferguson/c03bceec446e90814de474dfb20ad651 to your computer and use it in GitHub Desktop.
# Version 3.0
# PowerShell Config: ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
# Create profie with command:
# code $profile
# Commands List:
# cat -> bat
# e -> explorer
# act -> activate venv
# dact -> deactivate venv
# pattern -> create new pattern project
# update -> update all winget packages
# c -> open current directory in VSCode
# up, u -> cd ..
# rmd -> remove directory
# touch -> create new file
# rst -> rust build and run file
# ls -> eza medium details
# lsd -> eza full details
# l -> eza quick list
# alt+c -> fzf quick cd
# ctrl+f -> fzf open file in vscode
# ctrl+d -> fzf open directory in vscode
# ctrl+o -> fzf open directory in explorer
# Print CPU, GPU, and RAM size
# try {
# $ram = Get-CimInstance Win32_ComputerSystem | Select-Object -ExpandProperty TotalPhysicalMemory
# $ramGB = [math]::Round($ram / 1GB, 0)
# $cpu = (Get-CimInstance Win32_Processor | Select-Object -First 1 -ExpandProperty Name).Trim()
# # Truncate $cpu to only the first four space-separated words
# $cpu = ($cpu -split '\s+', 5)[0..3] -join ' '
# $gpu = (Get-CimInstance Win32_VideoController | Select-Object -First 1 -ExpandProperty Name).Trim()
# $ramGB = "$ramGB".Trim()
# Write-Host ("🖥️ $cpu / $ramGB GB / $gpu")
# } catch {
# Write-Host "Could not retrieve hardware info."
# }
#####################################################################
# START UP #
#####################################################################
Write-Host " "
try{
$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
Write-Host ("🤖 " + $user)
} catch {
Write-Host "Could not retrieve user info."
}
try{
Write-Host ("🐍 python " + ((python --version) -split ' ')[1])
} catch {
Write-Host "Python not installed or could not retrieve python version."
}
try{
Write-Host ("🐳 docker " + ((docker --version) -split ' ')[2].TrimEnd(','))
} catch {
Write-Host "Docker not installed or could not retrieve docker version."
}
try{
Write-Host ("🦀 rust " + ((rustc --version) -split ' ')[1])
} catch {
Write-Host "Rust not installed or could not retrieve rust version."
}
try{
Write-Host ("🧪 git " + ((git --version) -split ' ')[2])
} catch {
Write-Host "Git not installed or could not retrieve git version."
}
try{
Write-Host ("🍉 uv " + ((uv --version) -split ' ')[1])
} catch {
Write-Host "UV not installed or could not retrieve uv version."
}
# Start powershell with starship
Invoke-Expression (&starship init powershell)
# Init zoxide and replace cd with z
Invoke-Expression (& { (zoxide init --cmd cd powershell | Out-String) })
#####################################################################
# CUSTOM COMMANDS #
#####################################################################
# Replace cat with bat
Set-Alias cat bat
# Open current directory in Explorer
Set-Alias e Invoke-Explorer
function Invoke-Explorer {
param (
[string]$path = "."
)
$command = "ii $path"
Invoke-Expression $command
}
# Activate virtual environment
Set-Alias act .venv\Scripts\activate
Set-Alias dact deactivate
# New Pattern Project
function Invoke-NewPatternProject {
param (
[string]$project_name
)
$command = "uvx cookiecutter gh:wyattferguson/pattern"
Invoke-Expression $command
}
Set-Alias pattern Invoke-NewPatternProject
# Update everything
function Invoke-UpdateAll {
param ()
Invoke-Expression "winget upgrade --all --silent"
}
Set-Alias update Invoke-UpdateAll
# Open VSCode with Current Directory
function Invoke-VSCodeCurrentDirectory {
param ()
Invoke-Expression "code ."
}
Set-Alias c Invoke-VSCodeCurrentDirectory
# Up command
function Invoke-UP {
param (
[string]$filename
)
$command = "cd .."
Invoke-Expression $command
}
Set-Alias up Invoke-UP
Set-Alias u Invoke-UP
# Directory Delete - rmd command
function Invoke-DirDelete{
param (
[string]$directory
)
$command = "rm -r -force $directory"
Invoke-Expression $command
}
Set-Alias rmd Invoke-DirDelete
# touch command for single file creation
function Invoke-Touch {
param (
[string]$filename
)
$command = "echo null >> $filename"
Invoke-Expression $command
}
Set-Alias touch Invoke-Touch
#####################################################################
# RUST #
#####################################################################
function Invoke-RustBuildRun {
param (
[string]$filename
)
$baseFilename = $filename.Substring(0, $filename.Length - 3)
$command = "rustc $filename && $baseFilename.exe"
Invoke-Expression $command
}
Set-Alias rst Invoke-RustBuildRun
#####################################################################
# EZA Configuration #
#####################################################################
# EZA theme.yml location
$env:EZA_CONFIG_DIR = "$env:USERPROFILE\.config"
# Replace ls with min details EZA
function Invoke-MediumEza {
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Args
)
eza -la --icons=always --no-user --no-filesize --no-permissions --colour=always --no-symlinks --time-style '+%y/%m/%d %H:%M' @Args
}
Set-Alias ls Invoke-MediumEza
# Replace ls with all details EZA
function Invoke-FullEza {
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Args
)
eza -lamh --icons=always --colour=always --no-symlinks --time-style '+%y/%m/%d %H:%M' @Args
}
Set-Alias lsd Invoke-FullEza
# quick ls with l
Set-Alias l eza
#####################################################################
# FZF Configuration #
#####################################################################
# Quick cd
function Invoke-QuickCD {
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$input_path
)
$selected_directory = fd --type directory | fzf --height 70% --preview='eza -lahT --level=2 --no-permissions --icons=always --colour=always --no-symlinks --time-style "+%y/%m/%d %H:%M" {}' --header='Quick CD'
if ($selected_directory) {
Invoke-Expression (cd $selected_directory)
}
}
Set-PSReadLineKeyHandler -Key "alt+c" -ScriptBlock { Invoke-QuickCD }
# Fast open file in VSCode(Ctrl+f)
function Invoke-FZFCodeFile {
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$input_path
)
$selected_file = fzf --walker-skip .git,node_modules,target,.venv --preview 'bat -n --color=always {}' --header='Open file in VSCode'
if ($selected_file) {
code $selected_file
}
}
Set-Alias f Invoke-FZFCodeFile
Set-PSReadLineKeyHandler -Key "Ctrl+f" -ScriptBlock { Invoke-FZFCodeFile }
# Open directory in VSCode (Ctrl+d)
function Invoke-FZFCodeDirectory {
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$input_path
)
$selected_directory = fd --type directory | fzf --preview='eza -lahT --level=2 --no-permissions --icons=always --colour=always --no-symlinks --time-style "+%y/%m/%d %H:%M" {}' --header='Open Directory in VSCode'
if ($selected_directory) {
code $selected_directory
}
}
Set-Alias d Invoke-FZFCodeDirectory
Set-PSReadLineKeyHandler -Key "Ctrl+d" -ScriptBlock { Invoke-FZFCodeDirectory }
# Open directory in Windows Explorer (Ctrl+o)
function Invoke-FZFOpenDirectory {
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$input_path
)
$selected_directory = fd --type directory | fzf --preview='eza -lahT --level=2 --no-permissions --icons=always --colour=always --no-symlinks --time-style "+%y/%m/%d %H:%M" {}' --header='Open Folder in Explorer'
if ($selected_directory) {
ii $selected_directory
}
}
Set-Alias o Invoke-FZFOpenDirectory
Set-PSReadLineKeyHandler -Key "Ctrl+o" -ScriptBlock { Invoke-FZFOpenDirectory }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment