This powershell profile allows the use of aliases for git commands and adds other useful aliases and functions for web development.
- Open up Powershell
- Change directory to your docouments
cd $env:USERPROFILE\Documents
- Make the WindowsPowerShell directory and change to it
md WindowsPowerShell
cd WindowsPowerShell
- Create the PowerShell profile and open it on the PowerShell editor
New-Item Microsoft.PowerShell_profile.ps1 -ItemType "file"
powershell_ise.exe .\Microsoft.PowerShell_profile.ps1
- Set up the Execution Policy to allow your profile to run. To require that only scripts downloaded by the internet need to be signed by a trusted publisher, run the Execution policy below. If you followed the steps above, then you have created your own profile so it will be allowed to execute.
Set-ExecutionPolicy RemoteSigned CurrentUser
- Copy the functions you want into your profile. You can run the following command to refresh your profile on PowerShell.
. $profile
Now when you run PowerShell, the profile will be loaded automatically by PowerShell and the shortcut commands will be available to use.
You can get custom colors with the PSColor module (https://github.com/Davlind/PSColor). Easiest way to install is to use PsGet. To install PsGet:
(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
Then to install PSColor:
Install-Module PSColor
The dir (or ls if you have it) command will now have different colors for directories and filetypes. It can also be customized in the profile.
Alias: pse
Use this alias to navigate to Powershell directory and edit the profile in PowerShell ISE.
Alias: psr
Use this alias to reload the profile in Powershell
Alias: s
Command: git status
Alias: aa
Command: git add all
aa
=> git add .
Alias: c
Command: git commit -m
c "Commit message"
=> git commit -m "Commit message"
Alias: p
Command: git push origin
p master
=> git push origin master
Alias: pm
Command: git push origin master
pm
=> git push origin master
Alias: pl
Command: git pull origin
pl master
=> git pull origin master
Alias: plm
Command: git pull origin master
plm
=> git pull origin master
Alias: co
Command: git checkout
co master
=> git checkout master
Alias: b
Command: git branch
b --remote
=> git branch --remote
Alias: m
Command: git merge
m dev
=> git merge dev
Alias: cdwpp
Command: cd .\wp-content\plugins
If you use this alias from the root directory of your WordPress installation, then it will change the directory to the plugins directory
Alias: cdwpt
Command: cd .\wp-content\themes
If you use this alias from the root directory of your WordPress installation, then it will change the directory to the themes directory
Alias: up
Command: "../"
The up command will allow you to go up one directory from your current path
Alias: upnum
Command: "../" repeated by num
up2
The up2 command will allow you to go up two directories form your current path. The max number you can use is up10, which will allow you to go up 10 directories from your current path.