Overview
Custom functions are stored in individual files under~/.config/powershell/functions/ and automatically loaded by the 50-functions.ps1 module.
Function Directory Structure
Loading Mechanism
The50-functions.ps1 module automatically sources all .ps1 files in the functions directory:
Source: conf.d/50-functions.ps1
How It Works
Function Categories
File Operations
- mkcd - Create directory and navigate into it
- backup / bak - Create timestamped backups
- extract / unpack - Extract various archive formats
Search & Navigation
- rfv - Ripgrep + fzf + editor integration for code search
- ~, desk, docs, dl, dev, conf - Quick directory jumps
- ., …, … - Parent directory navigation
- - - Return to previous directory
JSON Processing
- jqc - Parse JSON from clipboard with jq
Shell Management
- reload - Reload PowerShell profile without restarting
- restart - Restart PowerShell with fresh process
WSL Integration
- wsl-here - Open current Windows directory in WSL
- Copy-ToWSL - Copy files from Windows to WSL
- Copy-FromWSL - Copy files from WSL to Windows
- wslrun - Execute commands in WSL
Adding New Functions
To add a new custom function:- Create a new
.ps1file in~/.config/powershell/functions/ - Define your function with proper documentation
- Optionally add aliases for convenience
- Reload your profile or restart PowerShell
Function Template
Example: my-function.ps1
Function Organization Strategies
Single Purpose Files
Most functions are in their own file for clarity:Grouped Functions
Related functions can be grouped in one file:navigation.ps1 contains
wsl-helpers.ps1 contains
Function Discovery
To see all loaded custom functions:Load Order Considerations
Functions are loaded:- After environment setup (10-environment.ps1)
- After aliases (20-aliases.ps1)
- After tool integrations (30-tools.ps1)
- Before prompt configuration (60-prompt.ps1)
- Use environment variables like
$env:EDITOR - Reference tools configured in earlier modules
- Access modern CLI tools (bat, fzf, ripgrep, etc.)
Benefits
Modular
Each function in its own file, easy to add/remove/modify
Automatic
New functions are auto-loaded, no manual registration
Documented
Functions use PowerShell’s built-in help system
Portable
Entire functions directory can be synced across machines
See Also
- Custom Functions - Detailed documentation for each function
- Profile Structure - How the module system works
- Aliases - Command shortcuts and abbreviations
