Introduction: Customizable Command Prompt

Picture of Customizable Command Prompt

Disclaimer: The original concept and the basic code behind this was created by Tuxmascot. However, I have slightly modified the code to make the code more versatile as well as adding my own little flair to it.

Have you ever wanted to use the Command Prompt, but the computer you were on had it locked? Or maybe you want the Command Prompt to have a certain color, but always get tired of having to set it when you start it. Whatever your reason, we've all wished that instead of using the standard Command Prompt, we could just make our own. Well no more! Today, I present you the solution to your problem. I give you an easily customizable program that does everything that the Command Prompt does, only it's more versatile! 

Step 1: Things You Will Need

Picture of Things You Will Need

Although this program is fairly simple to make, it will take some things to make:

1. A Windows computer. 
2. A basic understanding of batch files and how to make them.
3. A need for customization.
4. A spark of creativity.

Step 2: The Basic Code

Picture of The Basic Code

Something you must understand about this program is that there are to parts of the code; Layers, if you will. The first layer is the basic layer. This is the bare minimum required to have a functional program. The second layer will be talked about in the next step.

The basic code behind this program is as follows:

echo off

:command

set /p input=

%input%
goto command

What this code does is ask the user for input, then execute the input. So it is very important that anything put as input is in the batch language. Anything else will cause an error message. Another important thing to remember is that all of this is necessary to the program. Any fooling around with this code will cause the program to run improperly.  

Step 3: The Complex Code

Picture of The Complex Code

The second layer of the code is the complex layer. This is all the code that gives the program its true purpose. The basic layer makes this functional, but the complex layer makes this excellent. The problem with documenting the complex layer is that it is all very personal with what you do with the complex layer. You can add all sorts of things to your complex layer. An example might be programming it to greet you when you open the program, or perhaps telling you the time. 

An example of the complex layer:

echo off
cls

title Command Prompt
echo Hello.
color 2

:command

set /p input=Command:

%input%
goto command

This is where an understanding of batch programming really comes in handy. If you know a lot about batch, you can do a limitless amount of things with this custom Command Prompt. Here are a list of ideas to get you thinking:

1. Having the cls command as the program starts up -- When the program starts, you will notice a little message showing that echo is turned off. This is quite ugly looking and frankly, we could all do without it. So put that little command there and get rid of it before you even see it.

2. Having a title -- The default title for the program is C:\Windows\system32\cmd.exe. A real Command Prompt, though, has the title of Command Prompt. For people going for a realistic program, setting the title to be this is quite effective. If you're going for just a personal touch, perhaps naming it My Command Prompt.

3. Add a greeting message -- I know that I like it when my computer says things personally to me. So why shouldn't my command prompt greet me when I open it up? After all, it is my Command Prompt. I should be able to have it say whatever I want it to say to me. Also, adding a greeting makes the Command Prompt feel more like it's your own personal creation.

4. Changing the default color -- Haven't you ever wished that the Command Prompt automatically displayed your favorite colors when you opened it up? But having to change it every time is so annoying. But putting the color before the :command label is really simple and it doesn't affect how the rest of the colors work, should you choose to change to another color mid-session. 

5. Change the prompt -- Don't you wish that stupid little prompt would go away? After all, if you needed to know the path you were currently on, you can just type cd. And having to change it every time you enter the command prompt is really annoying. But by simply adding a few words after "set /p input=" you can have the computer show you whatever you want right before you type something in.

Comments

Timinator01 (author)2012-12-25

Here's my version for a nice green linux style terminal :

@echo off
cls

color 02
title Custom CMD
echo Start Directory: %CD%
echo.

:command

echo.
Set /p input=%username%@%computername%:~$

%input%
goto command

thegeeke (author)Timinator012012-12-31

Just out of curiosity, why did you put the cls after @echo off? I don't think it's needed... is it?

Timinator01 (author)thegeeke2013-01-01

No its not I used echo off at first and then I changed it to @echo off and didn't delete the cls

thegeeke (author)Timinator012013-01-01

OK, I just wanted to make sure I wasn't imagining things or something. ;)

thegeeke (author)2012-12-25

Try using @echo off. It works better. Also, just an FYI, you can also change the prompt by using the "prompt" command. :)

Ink Ninja (author)thegeeke2012-12-25

I've never noticed any real difference in using echo off as opposed to @echo off, but I could be wrong. Also, I considered using the "prompt" command, however, what we see as the prompt is not really the prompt, but the text displayed before an input. Because echo is off, the prompt is displayed anyway. 

thegeeke (author)Ink Ninja2012-12-26

The main difference between echo off and @echo off is that you don't have to do a cls after @echo off because the @ mutes the echo off prompt.  (See a quick little script I put together to demonstrate in the photo.)  One of the things programmers do not do anymore that they would do well to learn again is to write clean code.  By using one less command in the olden days, you made a program much faster.  Now that computers are faster, there isn't as much of a push to write cleaner, so they don't.  Those "one extra lines" add up quickly.  This is one of the reasons Windows 8 runs faster than even XP: because Microsoft went back and re-did about 95% of their coding to make it cleaner.  Don't get me wrong, I am not a "programmer", far from it.  I do a little for fun only very "basic" programs (pun intended), but I would love to see people start writing clean code again.  :)

I agree that in a batch file the prompt command wouldn't do anything, that is more or less when you are not able to use your batch file.  For instance, when I am on a client's computer, I will often do a quick customization because it is actually helps me focus.  (Weird, but it works)

Prof. Pickle (author)thegeeke2012-12-30

I completely agree with you on this.

I've currently decided that I desire a job in the field of programming (although I don't know what yet), and I've been reading dozens of articles on what you would do in a job, its requirements and tips on how to get it, and you know what always comes up?

Clean code.

It's a necessity if you want to continue down this line, but if you're a hobbyist, it doesn't matter as much.

thegeeke (author)Prof. Pickle2012-12-31

Thanks!

There is one company that you don't have to know how to write clean code for: Adobe! ;)

Even if you're a hobbyist (as I am), it's still nice to know. For instance, even though I don't do programming for a living, I do a lot with computer hardware. There was one time that I had to consult for a program that my employer at the time was making... it sure helped that I knew a little programming (even though I wasn't doing the actual coding). As a hobbyist, you are fine with writing "dirty" code... as long as you aren't telling others to do the same....... ;)

Prof. Pickle (author)thegeeke2012-12-31

Very true. The bad thing with having a mentor is that you tend to pick up their bad habits.

Another thing I've learnt from Instructables is that most jobs may involve programming at one point.

Anyway, once again I agree with you here, I only wish more people would respond quickly, or at least respond at all.

thegeeke (author)Prof. Pickle2012-12-31

But at the same time, you pick up their good habits, which normally outweigh the bad habits. ;)

Many computer jobs do, but you are not always the one writing the code. Often you are just working with the programmers telling them what you want to program to do, and let them figure it out.

Anyway, happy New Year, and I wish you the best of luck in pursuing a job in programming. :)

Prof. Pickle (author)thegeeke2012-12-31

Thank you, and ditto. I hope you achieve your New Years Resolution.

About This Instructable

3,586views

6favorites

License:

Bio: If you look at my interests, you'll know that I have an odd assortment of talents (which is good, because I'm an odd ... More »
More by Ink Ninja:Customizable Command PromptFunny Prank(s) (With VBS)Party Time 2 and Party Time 3.5 (an example walkthrough of editing a batch file)
Add instructable to: