Programming
EN
1 min read
Create aliases for commands on Windows
tf plan, tf apply... are they terraform?!

Create aliases for commands on Windows
Add command alias to your PowerShell in just a few minutes!
Imagine you can shorten your "
terraform init" to something like "tf init".Use with caution
You may find the alias overlapping other existing commands, so please consider when applying
Method 1 - Edit and apply the existing profileMethod 1 - Edit and apply the existing profile
Method 1 - Edit and apply the existing profileMethod 1 - Edit and apply the existing profile
Locate the fileLocate the file
Locate the fileLocate the file
Find the current profile file (
Microsoft.PowerShell_profile.ps1) of PowerShell at "$PSHOME\Microsoft.PowerShell_profile.ps1" AND "$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1"Enter aliasesEnter aliases
Enter aliasesEnter aliases
If exists, open the file, and add your aliases as following:
powershell
new-alias -Name tf -Value terraform new-alias -Name pn -Value pnpm
Add your aliases line by line.
Format: new-alias -Name -Value
Example, if you want to shorten pnpm install to pn install, then the value would be
powershell
new-alias -Name pn -Value pnpm
Save the file and restart your PowerShell.
If not exist, consider the method 2 below.
Method 2 - Create a new profile fileMethod 2 - Create a new profile file
Method 2 - Create a new profile fileMethod 2 - Create a new profile file
Create a file called "Microsoft.PowerShell_profile.ps1" under your desired folder, but common use is "$HOME\Documents\PowerShell"
Add your aliases config just like method 1 above.
Save and restart your PowerShell.
How to check $HOME variableHow to check $HOME variable
How to check $HOME variableHow to check $HOME variable
Type “$HOME” on your PowerShell!
Hope this helps!
