Showing posts with label windows shell. Show all posts
Showing posts with label windows shell. Show all posts

Tuesday, December 26, 2006

Simplest way to add "Cygwin Prompt Here" to Windows Explorer

Just like Eric Sink, the first thing I install on my windows laptop is Cygwin and, well not Emacs anymore, gvim. I just can't image using windows so pre-mature shell to get anything done. One little problem with Cygwin is since it uses a unix like directory structure, switching back and forth between Windows Explorer and Cygwin has been a pain in the ass for a long time. Now, time to scratch the itch.

A quick Google search redirects me to Bruce Eckel's article on this same problem. It proposes two solutions but unfortunately none of them works perfectly on my environment. After hacking around, here is my solution. Different from the existing ones, this is the simplest solution I could find so far. No .bashrc, no .bat file, only one tiny .reg file. Enjoy it and see my code comments in lines.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Cmd Here]
@="Cygwin &Prompt Here"
[HKEY_CLASSES_ROOT\Folder\shell\Cmd Here\command]
@="cmd.exe /c c:\\cygwin\\bin\\bash.exe --login -c \"cd '%1'; exec /bin/bash\""

Notes:

  1. Save the above text into any reg in any folder, double click it and you should be all set. (Assuming you're using the Cygwin default installation path, of course.)
  2. cmd.exe /c : launch the cmd.exe and execute the command after the /c parameter. Close the command window when the bash exits.
  3. bash.exe --login :load the user settings for the login user. -c means to execute the commands after login.
  4. cd %1; :retrieve the folder path from Windows Explorer
  5. exec /bin/bash: to open the bash environment.

Wednesday, December 20, 2006

Due to the nature of its graphical user interface, windows shell has been ignored for a long time. It's true that having a point-and-click interface doesn't require learning and remembering, but to boost your productivity, master the art of command line is a must. Be sure to install the cygwin environment and expose its bin folder into your %PATH% variable will bring tons of powerful Unix tools into your windows arsenal with almost no cost.

One thing I really love about the shell is its capability to jump right into your destination folder. For example, if you're developing your FireFox extension, following tips might be quite handy to you.

1. Jump into folders

set FIREFOX_INSTALL_DIR = "C:\Program Files\Mozilla Firefox"
set FIREFOX_DEV_PROFILE = "C:\Documents and Settings\adong\Application Data\Mozilla\Firefox\Profiles\k5b2sa
58.Dev"
// Now you could jump right into it by typing:
cd %FIREFOX_INSTALL_DIR%
cd %FIREFOX_DEV_PROFILE%
2. Start the FireFox in a 'dev' mode by
// instead of "C:\Program Files\Mozilla Firefox\firefox.exe" -P dev
set MOZ_NO_REMOTE=1
%FIREFOX_INSTALL_DIR%\firefox.exe -P dev
3. Or, find the merge point id for the "stausbar"
$ grep -r -n "statusbar .* id=" %firefox_install_dir% | grep ".\.xul:"