Powershell bashrc equivalent
Linux has a file called .bashrc which gets executed whenever a new terminal starts. This .bashrc file is generally used for
- Setting aliases
- Setting up environment variables
- Shortcut functions
In windows there is no .bashrc file. But there is a way to achieve the same functionality using powershell.
In this example we will download notepad++ and set an alias vim to open files in notepad++ from command prompt.
`vim
Steps
- First download notepad++. Google search , download and install.
-
Open powershell. Set an alias for notepad++. Here I am setting the alias
vimset-alias vim 'C:\Program Files\Notepad++\notepad++.exe'This will only work for the current shell. A new shell will not have this alias.
-
Create
$profilefile = powershell equivalent of linux.bashrc.> $profile C:\Users\<username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 > echo "set-alias vim 'C:\Program Files\Notepad++\notepad++.exe'" >> $profile -
Open another powershell session as administrator.
> Set-ExecutionPolicy RemoteSignedselect A
-
close all open powershell shells. Open a brand new powershell shell.
> vim $profile - This is the
.bashrcequivalent. Add more shortcuts and start up commands here.