Colored Prompt in KornShell
Clash Royale CLAN TAG#URR8PPP
up vote
11
down vote
favorite
According to this StackOverflow post, it is possible have a colored prompt in KornShell. I have not been able to figure out how to do this. I am able to use color:
echo -e "33[34mLinux33[00m"
gives a blue "Linux" output, as does:
printf "33[34mLinux33[00m"
However, when I incorporate the escape codes into my PS1
prompt variable, they are not being escaped. What do I need to do to get a colored prompt? Besides being something of a sucker for eyecandy, I find that a colored prompt is useful when visually parsing output.
colors prompt ksh
add a comment |
up vote
11
down vote
favorite
According to this StackOverflow post, it is possible have a colored prompt in KornShell. I have not been able to figure out how to do this. I am able to use color:
echo -e "33[34mLinux33[00m"
gives a blue "Linux" output, as does:
printf "33[34mLinux33[00m"
However, when I incorporate the escape codes into my PS1
prompt variable, they are not being escaped. What do I need to do to get a colored prompt? Besides being something of a sucker for eyecandy, I find that a colored prompt is useful when visually parsing output.
colors prompt ksh
add a comment |
up vote
11
down vote
favorite
up vote
11
down vote
favorite
According to this StackOverflow post, it is possible have a colored prompt in KornShell. I have not been able to figure out how to do this. I am able to use color:
echo -e "33[34mLinux33[00m"
gives a blue "Linux" output, as does:
printf "33[34mLinux33[00m"
However, when I incorporate the escape codes into my PS1
prompt variable, they are not being escaped. What do I need to do to get a colored prompt? Besides being something of a sucker for eyecandy, I find that a colored prompt is useful when visually parsing output.
colors prompt ksh
According to this StackOverflow post, it is possible have a colored prompt in KornShell. I have not been able to figure out how to do this. I am able to use color:
echo -e "33[34mLinux33[00m"
gives a blue "Linux" output, as does:
printf "33[34mLinux33[00m"
However, when I incorporate the escape codes into my PS1
prompt variable, they are not being escaped. What do I need to do to get a colored prompt? Besides being something of a sucker for eyecandy, I find that a colored prompt is useful when visually parsing output.
colors prompt ksh
colors prompt ksh
edited May 23 '17 at 11:33
Community♦
1
1
asked Jul 5 '12 at 18:19
Kazark
5902829
5902829
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
up vote
10
down vote
accepted
Just use a literal Esc character, entered with Ctrl-v,Esc (will be displayed as ^[
on the screen):
PS1="^[[34mLinux^[[00m"
Or use the output of the echo
command you find out is working:
PS1="$(echo -e "33[35mLinux33[00m")"
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
add a comment |
up vote
4
down vote
You need to put a literal escape character in the PS1
variable. Ksh88 and clones such as pdksh and mksh (older versions) have no literal syntax for control characters except through the print
built-in. Mksh understands e
for escape, but pdksh requires the octal code 33
.
PS1=$(print '33[34mLinux33[00m')
ATT ksh93 introduces the backlash-escaped literal syntax $'…'
(also available in mksh since R39b). You can use backslash escapes to put control characters in these literals.
PS1=$'e[34mLinuxe[00m'
2
Actually,mksh
also supports$'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.
– mirabilos
Feb 27 '14 at 14:01
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
add a comment |
up vote
2
down vote
I use these in mksh
for a user shell
:
# custom prompt see http://comments.gmane.org/gmane.os.miros.mksh/126
PS1=$'arae[1;34ma ^ ^ ^ ^ | ae[36ma$@$HOSTNAME%%.*ae[34ma | ^ ^ ^ ^ | ae[0;33ma$(local d=$PWD:-? p=~; [[ $p = ?(*/) ]] || d=$d/#$p/~;
print -nr -- "$d")ae[1;34ma |n ^ ^ ^ ^ | ae[32ma$(date +%H:%M)ae[34ma | ^ ^ >>ae[0ma '
& a slightly different shell
for root
:
PS1=$'arae[1;34ma ^ ^ ^ ^ ^ ae[31ma$ echo ?)@$HOSTNAME%%.*ae[34ma ^ ^ ^ ^ ^ ^ ^ ae[0;33ma$(
local d=$PWD:-? p=~
[[ $p = ?(*/) ]] || d=$d/#$p/~
print -nr -- "$d"
)ae[1;34ma ^ ^ n ^ ^ ^ ^ ^ ae[32ma$(date +%H:%M)ae[34ma ^ ^ ^ ^ ae[0ma '
As the special characters did not copy, here is a pastebin paste for both the normal user and root.
add a comment |
up vote
1
down vote
Several things are going on in people's answers, each involving a different syntax.
The escape sequences for your terminal program given in the documentation.
How to encode the terminal escape sequences in the PS1 variable, for example e or literal escape. This depends on the shell.
How to add changing information to the prompt, for example the hostname, current directory, etc. This also depends on the shell. You may be able to use special backslash sequences like w for the working directory, or you may have to name environment variables or embed command lines into the string.
How to tell the shell which characters print and which characters don't. The shell doesn't know where your terminal escape sequences begin and end. If the shell has a command-line editor or something similar, it needs to know which characters print so it knows where the cursor is. Without this detail, your prompt might look right but editing can behave strangely.
In bash, you put [ before each escape sequence and ] after.
In ksh, you choose a single nonprinting ASCII character that can't occur anywhere else in the string. At the beginning of the string, you write that character followed by an ASCII carriage return. Then you write the same character before and after each escape sequence. z3ntu chose a as the marker character.
add a comment |
up vote
0
down vote
Thanks to previous answers and other sources, I was able to come up with these:
Korn shell prompt:
PS1="$(echo "33[32m`logname`33[35m@33[32m`hostname` 33[33m`pwd`33[36mn$33[0m")"
Bash prompt:
PS1="[e[32m]u[e[35m]@[e[32m]h [e[33m]w[e[36m]n$[e[0m]"
These give the same coloured prompt (yes, I speak Queen's English ;) ) in the format:
username@computername /current/working/directory
$
The DOS equivalent (though there are no colour options) is:
prompt %username%@%computername% $P$_$G
which gives:
username@computername /current/working/directory
>
The ">" is keeping it 'DOSsy' rather than 'nixy' with "$", but if you wanted the sigil ("$") instead then it would be:
prompt %username%@%computername% $P$_$$
Provided your login account has the requisite permissions, to make the 'nixies' permanent prepend them with "export ":
export PS1="..."
and change the DOSsy to:
setx PROMPT "%username%@%computername% $P$_$G"
or
setx PROMPT "%username%@%computername% $P$_$$"
New contributor
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
10
down vote
accepted
Just use a literal Esc character, entered with Ctrl-v,Esc (will be displayed as ^[
on the screen):
PS1="^[[34mLinux^[[00m"
Or use the output of the echo
command you find out is working:
PS1="$(echo -e "33[35mLinux33[00m")"
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
add a comment |
up vote
10
down vote
accepted
Just use a literal Esc character, entered with Ctrl-v,Esc (will be displayed as ^[
on the screen):
PS1="^[[34mLinux^[[00m"
Or use the output of the echo
command you find out is working:
PS1="$(echo -e "33[35mLinux33[00m")"
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
add a comment |
up vote
10
down vote
accepted
up vote
10
down vote
accepted
Just use a literal Esc character, entered with Ctrl-v,Esc (will be displayed as ^[
on the screen):
PS1="^[[34mLinux^[[00m"
Or use the output of the echo
command you find out is working:
PS1="$(echo -e "33[35mLinux33[00m")"
Just use a literal Esc character, entered with Ctrl-v,Esc (will be displayed as ^[
on the screen):
PS1="^[[34mLinux^[[00m"
Or use the output of the echo
command you find out is working:
PS1="$(echo -e "33[35mLinux33[00m")"
answered Jul 5 '12 at 18:28
manatwork
21.4k38284
21.4k38284
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
add a comment |
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
It's at times like this that I realize I am yet a commandline noob. I usually feel so good in comparison to my friends. :) The first version worked nicely; what a neat trick! I didn't have success with the second version. +1
– Kazark
Jul 5 '12 at 18:57
add a comment |
up vote
4
down vote
You need to put a literal escape character in the PS1
variable. Ksh88 and clones such as pdksh and mksh (older versions) have no literal syntax for control characters except through the print
built-in. Mksh understands e
for escape, but pdksh requires the octal code 33
.
PS1=$(print '33[34mLinux33[00m')
ATT ksh93 introduces the backlash-escaped literal syntax $'…'
(also available in mksh since R39b). You can use backslash escapes to put control characters in these literals.
PS1=$'e[34mLinuxe[00m'
2
Actually,mksh
also supports$'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.
– mirabilos
Feb 27 '14 at 14:01
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
add a comment |
up vote
4
down vote
You need to put a literal escape character in the PS1
variable. Ksh88 and clones such as pdksh and mksh (older versions) have no literal syntax for control characters except through the print
built-in. Mksh understands e
for escape, but pdksh requires the octal code 33
.
PS1=$(print '33[34mLinux33[00m')
ATT ksh93 introduces the backlash-escaped literal syntax $'…'
(also available in mksh since R39b). You can use backslash escapes to put control characters in these literals.
PS1=$'e[34mLinuxe[00m'
2
Actually,mksh
also supports$'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.
– mirabilos
Feb 27 '14 at 14:01
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
add a comment |
up vote
4
down vote
up vote
4
down vote
You need to put a literal escape character in the PS1
variable. Ksh88 and clones such as pdksh and mksh (older versions) have no literal syntax for control characters except through the print
built-in. Mksh understands e
for escape, but pdksh requires the octal code 33
.
PS1=$(print '33[34mLinux33[00m')
ATT ksh93 introduces the backlash-escaped literal syntax $'…'
(also available in mksh since R39b). You can use backslash escapes to put control characters in these literals.
PS1=$'e[34mLinuxe[00m'
You need to put a literal escape character in the PS1
variable. Ksh88 and clones such as pdksh and mksh (older versions) have no literal syntax for control characters except through the print
built-in. Mksh understands e
for escape, but pdksh requires the octal code 33
.
PS1=$(print '33[34mLinux33[00m')
ATT ksh93 introduces the backlash-escaped literal syntax $'…'
(also available in mksh since R39b). You can use backslash escapes to put control characters in these literals.
PS1=$'e[34mLinuxe[00m'
edited Feb 27 '14 at 14:08
answered Jul 6 '12 at 1:21
Gilles
520k12510381569
520k12510381569
2
Actually,mksh
also supports$'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.
– mirabilos
Feb 27 '14 at 14:01
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
add a comment |
2
Actually,mksh
also supports$'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.
– mirabilos
Feb 27 '14 at 14:01
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
2
2
Actually,
mksh
also supports $'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.– mirabilos
Feb 27 '14 at 14:01
Actually,
mksh
also supports $'…'
– admittedly because Dave Korn (the Korn in Korn Shell) insisted I add it.– mirabilos
Feb 27 '14 at 14:01
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
@mirabilos Ah, thanks. I probably typed that answer on a machine with mksh R39 and didn't check newer versions.
– Gilles
Feb 27 '14 at 14:09
add a comment |
up vote
2
down vote
I use these in mksh
for a user shell
:
# custom prompt see http://comments.gmane.org/gmane.os.miros.mksh/126
PS1=$'arae[1;34ma ^ ^ ^ ^ | ae[36ma$@$HOSTNAME%%.*ae[34ma | ^ ^ ^ ^ | ae[0;33ma$(local d=$PWD:-? p=~; [[ $p = ?(*/) ]] || d=$d/#$p/~;
print -nr -- "$d")ae[1;34ma |n ^ ^ ^ ^ | ae[32ma$(date +%H:%M)ae[34ma | ^ ^ >>ae[0ma '
& a slightly different shell
for root
:
PS1=$'arae[1;34ma ^ ^ ^ ^ ^ ae[31ma$ echo ?)@$HOSTNAME%%.*ae[34ma ^ ^ ^ ^ ^ ^ ^ ae[0;33ma$(
local d=$PWD:-? p=~
[[ $p = ?(*/) ]] || d=$d/#$p/~
print -nr -- "$d"
)ae[1;34ma ^ ^ n ^ ^ ^ ^ ^ ae[32ma$(date +%H:%M)ae[34ma ^ ^ ^ ^ ae[0ma '
As the special characters did not copy, here is a pastebin paste for both the normal user and root.
add a comment |
up vote
2
down vote
I use these in mksh
for a user shell
:
# custom prompt see http://comments.gmane.org/gmane.os.miros.mksh/126
PS1=$'arae[1;34ma ^ ^ ^ ^ | ae[36ma$@$HOSTNAME%%.*ae[34ma | ^ ^ ^ ^ | ae[0;33ma$(local d=$PWD:-? p=~; [[ $p = ?(*/) ]] || d=$d/#$p/~;
print -nr -- "$d")ae[1;34ma |n ^ ^ ^ ^ | ae[32ma$(date +%H:%M)ae[34ma | ^ ^ >>ae[0ma '
& a slightly different shell
for root
:
PS1=$'arae[1;34ma ^ ^ ^ ^ ^ ae[31ma$ echo ?)@$HOSTNAME%%.*ae[34ma ^ ^ ^ ^ ^ ^ ^ ae[0;33ma$(
local d=$PWD:-? p=~
[[ $p = ?(*/) ]] || d=$d/#$p/~
print -nr -- "$d"
)ae[1;34ma ^ ^ n ^ ^ ^ ^ ^ ae[32ma$(date +%H:%M)ae[34ma ^ ^ ^ ^ ae[0ma '
As the special characters did not copy, here is a pastebin paste for both the normal user and root.
add a comment |
up vote
2
down vote
up vote
2
down vote
I use these in mksh
for a user shell
:
# custom prompt see http://comments.gmane.org/gmane.os.miros.mksh/126
PS1=$'arae[1;34ma ^ ^ ^ ^ | ae[36ma$@$HOSTNAME%%.*ae[34ma | ^ ^ ^ ^ | ae[0;33ma$(local d=$PWD:-? p=~; [[ $p = ?(*/) ]] || d=$d/#$p/~;
print -nr -- "$d")ae[1;34ma |n ^ ^ ^ ^ | ae[32ma$(date +%H:%M)ae[34ma | ^ ^ >>ae[0ma '
& a slightly different shell
for root
:
PS1=$'arae[1;34ma ^ ^ ^ ^ ^ ae[31ma$ echo ?)@$HOSTNAME%%.*ae[34ma ^ ^ ^ ^ ^ ^ ^ ae[0;33ma$(
local d=$PWD:-? p=~
[[ $p = ?(*/) ]] || d=$d/#$p/~
print -nr -- "$d"
)ae[1;34ma ^ ^ n ^ ^ ^ ^ ^ ae[32ma$(date +%H:%M)ae[34ma ^ ^ ^ ^ ae[0ma '
As the special characters did not copy, here is a pastebin paste for both the normal user and root.
I use these in mksh
for a user shell
:
# custom prompt see http://comments.gmane.org/gmane.os.miros.mksh/126
PS1=$'arae[1;34ma ^ ^ ^ ^ | ae[36ma$@$HOSTNAME%%.*ae[34ma | ^ ^ ^ ^ | ae[0;33ma$(local d=$PWD:-? p=~; [[ $p = ?(*/) ]] || d=$d/#$p/~;
print -nr -- "$d")ae[1;34ma |n ^ ^ ^ ^ | ae[32ma$(date +%H:%M)ae[34ma | ^ ^ >>ae[0ma '
& a slightly different shell
for root
:
PS1=$'arae[1;34ma ^ ^ ^ ^ ^ ae[31ma$ echo ?)@$HOSTNAME%%.*ae[34ma ^ ^ ^ ^ ^ ^ ^ ae[0;33ma$(
local d=$PWD:-? p=~
[[ $p = ?(*/) ]] || d=$d/#$p/~
print -nr -- "$d"
)ae[1;34ma ^ ^ n ^ ^ ^ ^ ^ ae[32ma$(date +%H:%M)ae[34ma ^ ^ ^ ^ ae[0ma '
As the special characters did not copy, here is a pastebin paste for both the normal user and root.
edited Jun 5 '16 at 11:02
z3ntu
5315
5315
answered Aug 3 '15 at 16:42
Stuart Cardall
72659
72659
add a comment |
add a comment |
up vote
1
down vote
Several things are going on in people's answers, each involving a different syntax.
The escape sequences for your terminal program given in the documentation.
How to encode the terminal escape sequences in the PS1 variable, for example e or literal escape. This depends on the shell.
How to add changing information to the prompt, for example the hostname, current directory, etc. This also depends on the shell. You may be able to use special backslash sequences like w for the working directory, or you may have to name environment variables or embed command lines into the string.
How to tell the shell which characters print and which characters don't. The shell doesn't know where your terminal escape sequences begin and end. If the shell has a command-line editor or something similar, it needs to know which characters print so it knows where the cursor is. Without this detail, your prompt might look right but editing can behave strangely.
In bash, you put [ before each escape sequence and ] after.
In ksh, you choose a single nonprinting ASCII character that can't occur anywhere else in the string. At the beginning of the string, you write that character followed by an ASCII carriage return. Then you write the same character before and after each escape sequence. z3ntu chose a as the marker character.
add a comment |
up vote
1
down vote
Several things are going on in people's answers, each involving a different syntax.
The escape sequences for your terminal program given in the documentation.
How to encode the terminal escape sequences in the PS1 variable, for example e or literal escape. This depends on the shell.
How to add changing information to the prompt, for example the hostname, current directory, etc. This also depends on the shell. You may be able to use special backslash sequences like w for the working directory, or you may have to name environment variables or embed command lines into the string.
How to tell the shell which characters print and which characters don't. The shell doesn't know where your terminal escape sequences begin and end. If the shell has a command-line editor or something similar, it needs to know which characters print so it knows where the cursor is. Without this detail, your prompt might look right but editing can behave strangely.
In bash, you put [ before each escape sequence and ] after.
In ksh, you choose a single nonprinting ASCII character that can't occur anywhere else in the string. At the beginning of the string, you write that character followed by an ASCII carriage return. Then you write the same character before and after each escape sequence. z3ntu chose a as the marker character.
add a comment |
up vote
1
down vote
up vote
1
down vote
Several things are going on in people's answers, each involving a different syntax.
The escape sequences for your terminal program given in the documentation.
How to encode the terminal escape sequences in the PS1 variable, for example e or literal escape. This depends on the shell.
How to add changing information to the prompt, for example the hostname, current directory, etc. This also depends on the shell. You may be able to use special backslash sequences like w for the working directory, or you may have to name environment variables or embed command lines into the string.
How to tell the shell which characters print and which characters don't. The shell doesn't know where your terminal escape sequences begin and end. If the shell has a command-line editor or something similar, it needs to know which characters print so it knows where the cursor is. Without this detail, your prompt might look right but editing can behave strangely.
In bash, you put [ before each escape sequence and ] after.
In ksh, you choose a single nonprinting ASCII character that can't occur anywhere else in the string. At the beginning of the string, you write that character followed by an ASCII carriage return. Then you write the same character before and after each escape sequence. z3ntu chose a as the marker character.
Several things are going on in people's answers, each involving a different syntax.
The escape sequences for your terminal program given in the documentation.
How to encode the terminal escape sequences in the PS1 variable, for example e or literal escape. This depends on the shell.
How to add changing information to the prompt, for example the hostname, current directory, etc. This also depends on the shell. You may be able to use special backslash sequences like w for the working directory, or you may have to name environment variables or embed command lines into the string.
How to tell the shell which characters print and which characters don't. The shell doesn't know where your terminal escape sequences begin and end. If the shell has a command-line editor or something similar, it needs to know which characters print so it knows where the cursor is. Without this detail, your prompt might look right but editing can behave strangely.
In bash, you put [ before each escape sequence and ] after.
In ksh, you choose a single nonprinting ASCII character that can't occur anywhere else in the string. At the beginning of the string, you write that character followed by an ASCII carriage return. Then you write the same character before and after each escape sequence. z3ntu chose a as the marker character.
answered Dec 28 '16 at 3:24
Derek Peschel
111
111
add a comment |
add a comment |
up vote
0
down vote
Thanks to previous answers and other sources, I was able to come up with these:
Korn shell prompt:
PS1="$(echo "33[32m`logname`33[35m@33[32m`hostname` 33[33m`pwd`33[36mn$33[0m")"
Bash prompt:
PS1="[e[32m]u[e[35m]@[e[32m]h [e[33m]w[e[36m]n$[e[0m]"
These give the same coloured prompt (yes, I speak Queen's English ;) ) in the format:
username@computername /current/working/directory
$
The DOS equivalent (though there are no colour options) is:
prompt %username%@%computername% $P$_$G
which gives:
username@computername /current/working/directory
>
The ">" is keeping it 'DOSsy' rather than 'nixy' with "$", but if you wanted the sigil ("$") instead then it would be:
prompt %username%@%computername% $P$_$$
Provided your login account has the requisite permissions, to make the 'nixies' permanent prepend them with "export ":
export PS1="..."
and change the DOSsy to:
setx PROMPT "%username%@%computername% $P$_$G"
or
setx PROMPT "%username%@%computername% $P$_$$"
New contributor
add a comment |
up vote
0
down vote
Thanks to previous answers and other sources, I was able to come up with these:
Korn shell prompt:
PS1="$(echo "33[32m`logname`33[35m@33[32m`hostname` 33[33m`pwd`33[36mn$33[0m")"
Bash prompt:
PS1="[e[32m]u[e[35m]@[e[32m]h [e[33m]w[e[36m]n$[e[0m]"
These give the same coloured prompt (yes, I speak Queen's English ;) ) in the format:
username@computername /current/working/directory
$
The DOS equivalent (though there are no colour options) is:
prompt %username%@%computername% $P$_$G
which gives:
username@computername /current/working/directory
>
The ">" is keeping it 'DOSsy' rather than 'nixy' with "$", but if you wanted the sigil ("$") instead then it would be:
prompt %username%@%computername% $P$_$$
Provided your login account has the requisite permissions, to make the 'nixies' permanent prepend them with "export ":
export PS1="..."
and change the DOSsy to:
setx PROMPT "%username%@%computername% $P$_$G"
or
setx PROMPT "%username%@%computername% $P$_$$"
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
Thanks to previous answers and other sources, I was able to come up with these:
Korn shell prompt:
PS1="$(echo "33[32m`logname`33[35m@33[32m`hostname` 33[33m`pwd`33[36mn$33[0m")"
Bash prompt:
PS1="[e[32m]u[e[35m]@[e[32m]h [e[33m]w[e[36m]n$[e[0m]"
These give the same coloured prompt (yes, I speak Queen's English ;) ) in the format:
username@computername /current/working/directory
$
The DOS equivalent (though there are no colour options) is:
prompt %username%@%computername% $P$_$G
which gives:
username@computername /current/working/directory
>
The ">" is keeping it 'DOSsy' rather than 'nixy' with "$", but if you wanted the sigil ("$") instead then it would be:
prompt %username%@%computername% $P$_$$
Provided your login account has the requisite permissions, to make the 'nixies' permanent prepend them with "export ":
export PS1="..."
and change the DOSsy to:
setx PROMPT "%username%@%computername% $P$_$G"
or
setx PROMPT "%username%@%computername% $P$_$$"
New contributor
Thanks to previous answers and other sources, I was able to come up with these:
Korn shell prompt:
PS1="$(echo "33[32m`logname`33[35m@33[32m`hostname` 33[33m`pwd`33[36mn$33[0m")"
Bash prompt:
PS1="[e[32m]u[e[35m]@[e[32m]h [e[33m]w[e[36m]n$[e[0m]"
These give the same coloured prompt (yes, I speak Queen's English ;) ) in the format:
username@computername /current/working/directory
$
The DOS equivalent (though there are no colour options) is:
prompt %username%@%computername% $P$_$G
which gives:
username@computername /current/working/directory
>
The ">" is keeping it 'DOSsy' rather than 'nixy' with "$", but if you wanted the sigil ("$") instead then it would be:
prompt %username%@%computername% $P$_$$
Provided your login account has the requisite permissions, to make the 'nixies' permanent prepend them with "export ":
export PS1="..."
and change the DOSsy to:
setx PROMPT "%username%@%computername% $P$_$G"
or
setx PROMPT "%username%@%computername% $P$_$$"
New contributor
New contributor
answered yesterday
skeetastax
1
1
New contributor
New contributor
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f42399%2fcolored-prompt-in-kornshell%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown