Getting the System prompt character in a Java program
Joined: May 07, 2003
Hi, Is there some way in which I can get the last character in the prompt sign of my system. For e.g. in Windows the prompt ends with a '>' sign. In Unix it might end with a '$' sign or a '#' etc. I want to know if this last character of the prompt can be accessed in a Java program.
Thanks in advance, Jayesh
Joined: May 22, 2005
Though I don't know if you could (easily) programatically capture this character, however, you might be interested in:
I'm not sure what the range of values this returns is, but you may be able to wrestle with it inside a switch construct to produce the desired effect.
If you figure out a better solution, let us know!
Joined: Jan 16, 2001
Why not find the OS type and then fix the prompt values accordingly !!
The prompt is configured via environment variables. In Windows, the environment variable is named "PROMPT". The default value is "$P$G" where "$P" indicates the path and "$G" indicates the greater-than character (other options include $D for current date and $T for current time). In the *nix world it's a bit more involved because one can configure colors as well as characters. By convention root uses a "#" and users have a "$". The "PS1" environment variable is what holds these values.