-
Notifications
You must be signed in to change notification settings - Fork 0
PowerShell Integration
This guide shows you how to make Forgum part of your PowerShell experience. After this, Forgum will greet you every time you open PowerShell.
Your PowerShell profile is a special file that runs automatically when you open PowerShell. Think of it like a "startup script" — anything you put in there runs every time.
Open PowerShell and type:
$PROFILEThis shows you the path to your profile file. It's usually something like:
-
Windows:
C:\Users\YourName\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 -
Mac/Linux:
~/.config/powershell/Microsoft.PowerShell_profile.ps1
# Open in Notepad (Windows)
notepad $PROFILE
# Open in VS Code (any platform)
code $PROFILE
# Open in Vim (Mac/Linux)
vim $PROFILEIf PowerShell says the file doesn't exist, create it:
New-Item -ItemType File -Path $PROFILE -ForceCopy and paste these lines into your profile file:
# ============================================
# Forgum - Fortune Cow for PowerShell
# ============================================
# Import the module
Import-Module Forgum -ErrorAction SilentlyContinue
# Show a cow with a random fortune when PowerShell starts
forgum- Save the file (Ctrl+S in most editors)
- Close PowerShell
- Open PowerShell again
You should see a cow with a fortune!
Import-Module Forgum -ErrorAction SilentlyContinue
forgumImport-Module Forgum -ErrorAction SilentlyContinue
# Pick a random cow and show a fortune
$cows = Get-CFCow
$randomCow = $cows | Get-Random
forgum -CowFile $randomCow.NameImport-Module Forgum -ErrorAction SilentlyContinue
# Use day of year to pick a consistent cow for the day
$cows = Get-CFCow
$dayCow = $cows[(Get-Date).DayOfYear % $cows.Count]
forgum -CowFile $dayCow.NameImport-Module Forgum -ErrorAction SilentlyContinue
# Enable rainbow colors
$config = Get-CFConfig
$config.lolcat.enabled = $true
Set-CFConfig -Config $config
forgumImport-Module Forgum -ErrorAction SilentlyContinue
# Only show fortune if this is the first PowerShell window
$hostWindow = (Get-Process -Id $PID).MainWindowTitle
if ($hostWindow -eq 'Windows PowerShell' -or $hostWindow -eq 'pwsh') {
forgum
}These are complete, ready-to-use profile snippets for common setups.
# ============================================
# Forgum - Basic Fortune Cow
# ============================================
# Shows a cow with a random fortune every time PowerShell opens.
Import-Module Forgum -ErrorAction SilentlyContinue
# forgum calls the default cow and a random fortune
forgumExpected output:
╭─────────────────────────────────────────╮
│ The best way to predict the future is │
│ to invent it. │
╰─────────────────────────────────────────╯
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
# ============================================
# Forgum - Random Thoughts + Fixed Animal
# ============================================
# Always uses the tux cow with a random fortune.
Import-Module Forgum -ErrorAction SilentlyContinue
function Show-FortuneCow {
$fortune = Get-Fortune
forgum -Text $fortune -CowFile 'tux'
}
# Call on startup
Show-FortuneCowExpected output:
╭─────────────────────────────────────────╮
│ The best way to predict the future is │
│ to invent it. │
╰─────────────────────────────────────────╯
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/
# ============================================
# Forgum - Random Thoughts + Fixed Animal + Rainbow
# ============================================
# Shows tux cow with fortune and rainbow colors.
Import-Module Forgum -ErrorAction SilentlyContinue
function Show-FortuneCow {
$fortune = Get-Fortune
forgum -Text $fortune -CowFile 'tux' -Lolcat
}
# Call on startup
Show-FortuneCowExpected output: Same as Pattern 2 but with rainbow-colored text.
# ============================================
# Forgum - Random Thoughts + Random Animal
# ============================================
# Picks a random cow each time with a random fortune.
Import-Module Forgum -ErrorAction SilentlyContinue
function Show-FortuneCow {
$fortune = Get-Fortune
$cow = (Get-CFCow | Get-Random).Name
forgum -Text $fortune -CowFile $cow
}
# Call on startup
Show-FortuneCow# ============================================
# Forgum - Config-Based Toggle
# ============================================
# Reads cow and lolcat settings from config.json.
# Edit config.json to change cow/lolcat without touching the profile.
Import-Module Forgum -ErrorAction SilentlyContinue
function Show-FortuneCow {
$config = Get-CFConfig
# If config says random, pick random cow; otherwise use configured cow
if ($config.cow.random) {
$cow = (Get-CFCow | Get-Random).Name
} elseif ($config.cow.file -ne 'default') {
$cow = $config.cow.file
} else {
$cow = 'default'
}
# Build parameters
$params = @{
Text = (Get-Fortune)
CowFile = $cow
}
# Add Lolcat flag if enabled in config
if ($config.lolcat.enabled) {
$params['Lolcat'] = $true
}
forgum @params
}
# Call on startup
Show-FortuneCowTo toggle lolcat: Edit your config.json and set "enabled": true under lolcat. No profile changes needed.
Add these handy shortcuts to your profile:
# Quick fortune
function ff { forgum }
# Fortune with a specific cow
function fc { param([string]$Cow) forgum -CowFile $Cow }
# Toggle rainbow
function lolcat {
$config = Get-CFConfig
$config.lolcat.enabled = -not $config.lolcat.enabled
Set-CFConfig -Config $config
Write-Host "Rainbow: $(if ($config.lolcat.enabled) {'ON'} else {'OFF'})" -ForegroundColor $(if ($config.lolcat.enabled) {'Magenta'} else {'Gray'})
}
# Change settings permanently
# Usage: forgum-set -Cow dragon -Lolcat $true
function forgum-set { Set-Forgum @args }
# Random cow gallery (shows 3 cows)
function cowgallery {
Get-CFCow | Get-Random -Count 3 | ForEach-Object {
forgum -Text (Get-Fortune) -CowFile $_.Name
}
}Forgum's configuration is shared across all shells (PowerShell, Bash, Zsh, Fish) because they all read from the same config.json file.
You can use Set-Forgum in your PowerShell $PROFILE to ensure certain settings are always applied when you start a session:
# Force a specific cow and animation every time PowerShell starts
Set-Forgum -Cow dragon -Animation bounceIf you primarily use Bash or Zsh but want to change Forgum settings without opening PowerShell, you can add an alias to your .bashrc or .zshrc:
# Add to ~/.bashrc or ~/.zshrc
alias forgum-set='pwsh -Command "Set-Forgum"'
# Now you can use it directly from Bash:
# forgum-set -Cow tux -Animation talking| Line | What It Does |
|---|---|
Import-Module Forgum |
Loads Forgum into PowerShell |
-ErrorAction SilentlyContinue |
Ignores errors if Forgum isn't installed |
forgum |
Shows a cow with a random fortune |
Get-CFConfig |
Reads the current settings |
Set-CFConfig |
Saves new settings |
"Import-Module : The specified module 'Forgum' was not loaded"
- Forgum isn't installed yet. Go back to Getting Started.
"forgum : The term 'forgum' is not recognized"
- The import line might have an error. Check for typos.
No cow appears on startup
- Make sure
forgumis on its own line in your profile. - Restart PowerShell to test.
PowerShell startup hangs for 30+ seconds after adding Forgum to my profile
- Root cause: Forgum's animation engine runs an infinite loop when
animation.modeis set to anything other thanstatic(e.g.talking,typewriter,bounce,disco). When an animation fires during profile load, the loop never exits and PowerShell cannot finish startup. -
Fix 1 — disable animations for startup (preferred): set
animation.mode = 'static'in your config:Or in$config = Get-CFConfig $config.animation.mode = 'static' Set-CFConfig -Config $config
config.json:{ "animation": { "mode": "static" } } -
Fix 2 — skip auto-start for the current session:
This is useful when the config is read-only or you're locked out of editing it.
$env:FORGUM_NOAUTOSTART = '1' Import-Module Forgum
After applying either fix, restart your PowerShell window. Startup should return to under one second.
Back: Getting Started | Next: Bash & Zsh Integration →