Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Reference: https://stackoverflow.com/a/29806921/7753274
- # Store the following code in $PROFILE.CurrentUserAllHosts
- # Note that the $PROFILE.CurrentUserAllHosts is different for VSCode and Terminal
- # Reference: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.3
- # Run the following command once in PowerShell as Administrator before running this script for the first time
- # Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
- # Reference: https://learn.microsoft.com/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.3
- # Reference: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-7.3
- Function NPM-Run {
- param (
- [string]$env = "dev"
- )
- npm run $env
- }
- Set-Alias -Name run -Value NPM-Run -Description "User defined alias"
- Set-Alias -Name d -Value NPM-Run -Description "User defined alias"
- Function NPM-Install-Prettier-Tailwind {
- npm install -D prettier prettier-plugin-tailwindcss
- }
- Set-Alias -Name prettier-tailwind -Value NPM-Install-Prettier-Tailwind -Description "User defined alias"
- Function Vite-Init {
- param (
- [Alias("n")][string]$projectName = ".",
- [Alias("t")][string]$template,
- [switch]$NoInstall
- )
- if($template) {
- npm init vite@latest $projectName -- --template $template
- } else {
- npm init vite@latest $projectName
- }
- if(-not $NoInstall) {
- Set-Location $projectName
- npm install
- npm run dev
- }
- }
- Set-Alias -Name vite -Value Vite-Init -Description "User defined alias"
- # ============================================================
- Function Git-Commit {
- param (
- [Parameter(Mandatory, HelpMessage="Enter the commit message.")][string]$message,
- [string]$description = ""
- )
- if($description) {
- git commit -m $message -m $description
- } else {
- git commit -m $message
- }
- }
- Set-Alias -Name gco -Value Git-Commit -Description "User defined alias"
- Function Git-Add-and-Commit {
- git add *
- Git-Commit
- }
- Set-Alias -Name gac -Value Git-Add-and-Commit -Description "User defined alias"
- # ============================================================
- Function Create-New-File {
- param (
- [Parameter(Mandatory, HelpMessage="Enter the file path.")][string]$filePath
- )
- if(Test-Path $filePath) {
- Write-Host "$filePath already exists"
- } else {
- New-Item -Path $filePath -ItemType File -Force
- }
- }
- Set-Alias -Name new -Value Create-New-File -Description "User defined alias"
- # ============================================================
- Write-Host "User defined aliases" -NoNewline
- $userDefinedAliases = Get-Alias | Where-Object {$_.Description -match "User defined alias"} | Select-Object -Property Name, Definition
- $userDefinedAliases
Advertisement
Add Comment
Please, Sign In to add comment