I have a PowerShell script that opens all files and programs related to my development environment. Rather than typing
> &.\mysetup.ps1
is there some way I can alias it to just type
> gosetup
?
Ideally I'll use this functionality for other PowerShell scripts as well! For reference, I want to run these commands from the Git PowerShell window.
In your profile, add the following lines:
$ps_script_dir = "C:\path\to\scripts"
New-Alias <alias name> $ps_script_dir\<script name>
Open a new shell, and you should be able to call your script by its alias.
Update / Additional Information
If you want to simply assign a one-liner, or a short snip of code to an alias, you don't need to put it into a script file, as described above, you can simply create a function in your profile:
function someUsefulOneliner
{
# Your one-liner goes here
}
set-item -path alias:<alias name> -value someUsefulOneliner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With