If you are like me who shuffles a lot between Linux and Windows OS, you surely miss many Linux shell commands in Windows Command Prompt and you definitely wish if you can replicate those commands somehow in Windows to make life little bit easier. One of those commands is navigating back to previous directory. In Linux, you can just type:
and voila, you go back to your previous directory. No need to check paths of previous entered directories. That’s one handy command. As usually happen with most productive shell commands, there is no equivalent command parameter in DOS.
I was looking for some kind of workaround to achieve same in DOS but when I couldn’t find any solution online so I decided to devise and build my own solution. It started with a very basic DOS batch file which just simulate Linux cd – command but slowly and gradually it grows over the period of time as I added more and more features.
So how does it work? To implement this solution, you will need two batch files: ccd.bat and dos_init.cmd. ccd.bat will have actual batch commands which take care of redirecting command to appropriate branch and keeping history of visited directories whereas dos_init.cmd will create DOSKEY aliases for cd command. You should create both files in one of your PATH directories (for example C:\Windows) so that DOS will able to locate these in Command Windows.
if '%*'=='' goto show_current_directory
if '%*'=='~' goto home_directory
if '%*'=='-d' goto my_documents_directory
if '%*'=='-p' goto program_files_directory
if '%*'=='-w' goto windows_directory
if '%*'=='--' goto previous_directory
if '%*'=='-' goto toggle_directory
doskey cd=ccd $*
doskey cd..=ccd ..
doskey cd--=ccd --
doskey cd-=ccd -
You always require to run dos_init.cmd before using ccd.bat so that assign aliases are available for ccd batch file. To automate that, you can simply add an entry in Windows Registry which will automatically run dos_init.cmd command every time you open Command Windows.
Following are steps to create above Registry entry. Be careful when editing the registry and make sure you know what you’re doing.
- Open Windows Registry.
- Go to to registry path: [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
- Create a registry entry with key as “AutoRun” and value as complete path of your dos_init.cmd
And that’s all we need.
Let’s go through the usage of this batch file:
Type cd- to toggle between last and current directory.
Type cd-- to go back to previous directories.
Few more examples to changing directory to system folders using this solution.
I hope you will find this solution useful. So how you want to further enhance this batch file? Please do share your changes and improvements here so that others can also benefit.
Finding that great background pattern for web application is hard and sometime very daunting task. We have all been there. We spend hours to search around for a decent background pattern, but we usually end up with patterns that are either too much on the face or have quality leaves much to be desired. I just found a great online resource which has huge collection of professional quality patterns for designers and developers. You must checkout SubtlePatterns.com.
One feature I like most on SubtlePatterns is that I can click on the preview button of any pattern and I can see how that pattern will actually look like as background of the page. What a great time saving feature! It happens a lot to me if I am very particular about the pattern I want use on my web site. I found a great looking background pattern somewhere, but when I drop that pattern on my web site, it comes out to be too dominating for the page. With preview functionality, you can see how that background pattern will actually look like before downloading and implementing on your web site.
You can use patterns from SubtlePatterns in commercial projects as well as long as you provide proper credit SubtlePatterns.com somewhere in the project.