Thursday, May 3, 2012

Enviornment - (My own little world)

As I progress through my personal and professional development career I have begun to notice the importance of 'good notes' and how helpful it is to share them as well as to receive feedback on your experiments and projects. That is the purpose of this blog. This is my place to share my thoughts and notes on my personal software development projects.

Today's notes are on my Windows Workstation. As any good professional knows, having a familiar work space, good tools, and solid organization makes work exceptional easy. While windows is not my favorite operating system it is the most commonly used operating system on the planet, therefore it naturally feels like a good place to start, as this would cover the widest audience.

In the wold of computers a stable development environment is a constantly moving target in which the good tools are powerful (often dangerous) and staying organized is a matter of keeping up with the latest convention or configuration. Depending on the model and mode of operations you may have to change how your computer works.

As I have learned over the years, software development, means that you have to be able to not only re-construct your projects or experiments quickly but re-construct your platforms as well.  In my early development years (college) I had not yet learned how important this actually is nor how important it is to make this environment my own.

The Shell (Home sweet Home, turtle... turtle...):

Notes: http://technet.microsoft.com/library/cc750982.aspx

Windows Shell is a strange world to operate in because unlike the Linux or Unix worlds your Windows shell is purely graphical and not text based. This means that when thinking about a problem a Windows developer often is so focused on the User Interface and how to make user operations simple.  This is is not necessarily a bad thing, however when it comes to automation the Windows developer has to resort to the Text interface, the Command Prompt.

Making this place  truly your home is important because once you learn the power of making Windows operate from the command line, you will never repeat a single task again. Trust me on this one.

The PROMPT variable, and yes it's all capitalized is an interesting way for you to make your shell a special place to live and work. Try this, type PROMPT=$_$T$S$P$_CMD$G$G.

Your prompt will be changed to separate one command execution from the start of the next command execution. It will also show you the time and your current full path as well as give you your own working space to type commands.
19:48:39.86 C:\
CMD-->
You can set this permanently by typing %windir%\system32\SystemPropertiesAdvanced.exe 
Not only can you start this Control Panel menu from the command prompt but you can start others...
I recommend  you keep this as a personal environment variable as opposed to making it a systems environment variable.

But this is not the only Command Prompt modification that I want to discuss, there is also the DOS key. To be brief, this allows you to create an alias, similar to those available in *nix environments. 

You can try it by typing doskey ls=dir $*, this will allow you to create short cuts for your shell session, but you can save the by typing doskey /MACROS:ALL > {storage_file}

This can then be loaded in two different ways, by typing doskey /MACROFILE={storage_file}, or by starting the command prompt with by this this command. There are two options when implementing this: set up a short cut to start the command prompt with the /k option or an alternative method as I'll discuss later. I recommend creating shortcut to start the command prompt this command. This will keep you from having to load your macros every time you start a new command prompt. 

For a more advanced or permanent solution, that works where you need it, you can alter three registry keys to call a global macros file.  I recommend putting the macros file somewhere global like 'Program Files' or 'Users\Share'.
[HKEY_CLASSES_ROOT\Drive\shell\cmd\command]@="cmd.exe /s /k pushd \"%V\" && doskey /macrofile=\"C:\\Program Files\\macros\""
[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]

@="cmd.exe /s /k pushd \"%V\" && doskey /macrofile=\"C:\\Program Files\\macros\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd\command]

@="cmd.exe /s /k pushd \"%V\" && doskey /macrofile=\"C:\\Program Files\\macros\""
;This is the most important key the other two cover specific scenarios.
If you place this into a registry file, text file with a '.reg' extension, you can execute that file by clicking on it. This will enable you to press 'Shift' + 'Right Click' to 'Open Command Prompt Here' and load your macros, any where on you wish to have a command prompt.

I would like to tell you how to make this macro file user specific with the %HOMEPATH% environment variable but the default key is of REG_SZ type and not of REG_EXPAND_SZ. It is because of this that you can't have each user define there own macro file and use this variable to load that macro file.  Major flaw to my implementation.


With these two simple modifications you can easily customize your command prompt to be your own and  allow yourself to fine tune your operations and become more effective. Remember to check out setting defaults in the command prompt, so that all your prompts will look the same. 

No comments:

Post a Comment

Its the little things (like opening a web browser)

Sometimes as your developing a solution/script for a problem your faced with interesting challenges where the dumbest workaround (opening a ...