In this tutorial I will show you how to create your own PS1
in Korn Shell
- The first thing you need to do is open up your .kshrc
Here is my .kshrc opened.
- You do not need to use nano, you can use whatever text editor you want. I, in this tutorial will be using vim.
- If you do not have a .kshrc, simply open your terminal and type(Make sure its in your home directory):
- Once you opened your .kshrc, you want to add this line:
Now, were going to do some fun stuff!
- Here are some options you can add to your PS1.
To add these options to your PS1 you simply do this:
- Note that to add these options its the ` `, not ' '.
- These are not ALL the options. You can do this with any command.
- Now we will get into colors, and more!
Note: Sorry about this guys, I am horrible in paint.
Now you're probably asking yourself. "Wow! These are awesome features! So how to I use this black magic?"
Well the answer is simple.
You just replace 'X' with the color or thing you want. For example.
This will print out red text.
So if you want a certain command or text to be red in your PS1, you just do this.
What this is saying is that you want red text, so your logname will be red. However everything AFTER logname will be lightgray. If you did not add that last color, everything you type will be red.
Now, if you want to add numbers 0-5 and 22-25 to your PS1, you do the same thing.
What this says is, make logname blink, and everything AFTER logname not blink.
Remember, if you don't add the turn off blink, everything you type will blink.
- You can combine these codes together, for example.
Notice how I put 4;31? That is saying make it blink, with red text.
Same in 0;37. That says make it normal text with light gray color.
- You can do this with the background colors too.
In 41;34, this says, make it a red background, with blue text.
- Now what if you don't want to add any commands to your PS1? What if you just want your PS1
to say "I love ksh >" in blue text? Well this is simple.
All you have to do is add " " or ' ' to your PS1.
$'\E[0;34m'"I love ksh > "$'\E[0;37m'
PS1=$'\E[0;34m''I love ksh > '$'\E[0;37m'
And that's it! Now you can start creating your OWN PS1.
Just in case you're curious. Here is my old PS1.
PS1='['$'\E[33m'`logname`$'\E[37m'''@''$'\E[34m'`hostname -s`$'\E[37m']'--Â» '
What this is saying is print '[' then make everything after that Yellow.
Then print my logname in yellow text. Then it says, make everything
after logname light gray. It will now print @ in light gray. After that it
says everything after @ to be blue. Now it will print my hostname in
blue. And lastly, everything after my hostname to be in light gray,
it will then print --Â» and everything I type in gray.
I hope this tutorial has helped anyone out there. I tried to make it as easy as I can so everyone can understand.
If you created your .kshrc, and nothing seems to be working. Create or open your .profile.
If you don't have a .profile. Do this.
And add this:
Make sure its in your home directory.
ENV=$HOME/.kshrc; export ENV