Just discovered doskey emacs=emacs -nw $*, but without something like .bashrc, I'll have to type that every time I start a shell, right?
This is a very good question. I found this. I suppose you could make a cmd script and have it run when starting cmd :-?
; Run a command when CMD.exe starts [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor] "AutoRun"=-
I just tried it. I have
AutoRun=C:\mini\bashrc.cmd and bashrc.cmd is
@echo off set TEST_VAR=something
when I start cmd and enter
echo %TEST_VAR% it says
something. So it works :)
You can create a shortcut to
cmd.exe and add the
/k switch to run a certain .bat file on startup, something like this:
cmd.exe /k "%HOMEDRIVE%\%HOMEPATH%\cmd-startup.bat"
cmd-startup.bat in your home dir would then work just like
Modification of mc3b's answer for those who are windows noobs like myself.
Make a file in
C:\bashrc.cmd or wherever you want your "rc" file to reside.
@echo off set TEST_VAR=something
regedit by searching for it or running it in cmd.
In the folders on the left navigate to:
Right click on the
Command Processor folder and click
New -> String Value. Enter the key
AutoRun. Double click on
AutoRun and enter the bashrc location
Test: Open a new cmd window and type:
if it says
something, it works.
Assuming your shell is Powershell, not cmd, you can create a profile for your shell. Such profiles basically are scripts which are executed when you start a shell. Just like
.bashrc. An important part of this post might be the following:
The locations (on Windows Vista) of the profiles for the powershell.exe host are as follows:
This is for all users of the computer and for all shells.
This is for all users of the computer, but it is only for the Microsoft.PowerShell shell.
This is for the current user only and all shells.
This is for the current user only and only for the Microsoft.PowerShell shell.
These profiles aren't created by default. They exist only if you create them.
It seems to be the same on Windows 7, 8 and 10. You can also find more information here.
Note: You may need to run the following. Otherwise, your profile may not be executed.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
You can also run the following as administrator to change the configuration for all users.
EDIT: Found this: http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx
To expound on Martin's solution (the shortcut), here's the PowerShell equivalent.
NOTE: You will need to have PowerShell script execution enabled. If this is disabled, you'll need to run an elevated PowerShell and execute
Set-ExecutionPolicy Unrestricted. Obviously, this is not recommended for security reasons, but there ya go.
powershell.exe -noexit -File "%HOMEDRIVE%\%HOMEPATH%\ps-startup.ps1"
Have a file named
ps-startup.ps1 in your user directory and your shortcut will execute it as a PowerShell file on startup. Just run PowerShell with this shortcut from here on out.
Basically nc3b's answer works, but Chocolatey's DevBox-Common package will make it easier.
- If you have not already installed Chocolatey, install it.
- Install DevBox-Common package by
choco install devbox-common -y
- You should type this command inside administrative cmd.exe or PowerShell.
- Now you have
.bashrc.include.aliases-common.batin your home path. Every file matching
.bashrc.include.*.batwill be executed at every command shell start.