LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   customizing the prompt (https://www.linuxquestions.org/questions/linux-newbie-8/customizing-the-prompt-905585/)

soundie 09-29-2011 06:40 AM

customizing the prompt
 
Hi guys,
I'm interested in modifying my gnome-terminal prompt, and I'm reading the ''Bash prompt How to'' from TheLinuxDocumentationProject.
How and where can I take the VGA font rpm for my emulator terminal in Centos 6?

thanks

jdkaye 09-29-2011 07:08 AM

Salve and Welcome to LQ,
This may help you.
I'm not sure if this font is still available.
ciao,
jdk

soundie 09-29-2011 07:24 AM

Quote:

Originally Posted by jdkaye (Post 4485474)
Salve and Welcome to LQ,
This may help you.
I'm not sure if this font is still available.
ciao,
jdk

Thanks jdk!
I thought, reading in internet, this font is obsolete...so what font do you advise me to have a more cool and friendly prompt?

jdkaye 09-29-2011 07:31 AM

I am a nonno but I admit to being totally cool and friendly. ;)
Have a look in /usr/share/consolefonts/ if that's where they're kept in CentOS
This guy has some ideas. Check it out. If you find something cool you can tell us.
ciao,
jdk

soundie 09-29-2011 08:01 AM

Quote:

Originally Posted by jdkaye (Post 4485491)
I am a nonno but I admit to being totally cool and friendly. ;)
Have a look in /usr/share/consolefonts/ if that's where they're kept in CentOS
This guy has some ideas. Check it out. If you find something cool you can tell us.
ciao,
jdk

Ok! Thanks jdk! :)

TB0ne 09-29-2011 09:05 AM

Quote:

Originally Posted by soundie (Post 4485508)
Ok! Thanks jdk! :)

And I'll chime in too. I use yakuake, so it's easy to set other fonts. But I do customize my prompt. Try putting these into your .bashrc:
Code:

PS1="\[\033[1;36m\][\u@\[\033[1;37m\]\h:\[\033[1;33m\]\w]\\$\[\033[0m\] "
SUDO_PS1="\[\033[1;31m\][\u@\[\033[1;37m\]\h:\[\033[1;33m\]\w]\\$\[\033[0m\] "

Hideous, I know. But, turns out pretty good. The standard PS1 prompt will be like this:
Code:

[user@hostname:directory]$
...and the prompt when you go into a SUDO shell "sudo -s" will be:
Code:

[user@hostname:directory]$
to give you a visual clue that you're running as root, and should be careful. Changing the second number (it's a 1;36m for regular, 1;31m for sudo in the above examples), will let you change the colors.

soundie 09-30-2011 02:58 AM

Quote:

Originally Posted by TB0ne (Post 4485566)
And I'll chime in too. I use yakuake, so it's easy to set other fonts. But I do customize my prompt. Try putting these into your .bashrc:
Code:

PS1="\[\033[1;36m\][\u@\[\033[1;37m\]\h:\[\033[1;33m\]\w]\\$\[\033[0m\] "
SUDO_PS1="\[\033[1;31m\][\u@\[\033[1;37m\]\h:\[\033[1;33m\]\w]\\$\[\033[0m\] "

Hideous, I know. But, turns out pretty good. The standard PS1 prompt will be like this:
Code:

[user@hostname:directory]$
...and the prompt when you go into a SUDO shell "sudo -s" will be:
Code:

[user@hostname:directory]$
to give you a visual clue that you're running as root, and should be careful. Changing the second number (it's a 1;36m for regular, 1;31m for sudo in the above examples), will let you change the colors.


Hi TBOne
thanks for answering!!
I've already colored my prompt, but now I'd want to use some kind of special caracter like this '---' to create a sort of a 'futuristic architecture'...like this http://imagecdn.maketecheasier.com/2...hprompts-7.jpg , but in many linux documentation they talk about installing some special font (like VGA font but maybe it is very old) to visualize the exact escape sequencing...infact, if I use some of the prompt configuration posted in internet, I don't have the same result! :(
The problem is that I don't know what kind of font I need and how to use it (i'm trying to learn the art of scripting in shell, and maybe this will b my first ''serious'' script :)

rhowaldt 09-30-2011 04:29 AM

not sure if this is what you are looking for, but those strange-looking lines and stuff are Extended ASCII (see here: http://www.cdrummond.qc.ca/cegep/inf...iles/ascii.htm). the Terminus-font should be able to render this i think.

colucix 09-30-2011 04:39 AM

You can customize your prompt with symbols from the Unicode table. To generate Unicode characters you have to use a terminal or an editor that support them. To type them, press simultaneously Ctrl-Shft-U, then type the code and press enter. The unicode character will appear, provided you have a font from which that character is available. Gnome-terminal and Firefox support this method.

In alternative you can open a VIM session, press I to enter in insert mode, then press Ctrl-V, then U, then the code and the character appears. You can copy and paste them in your PS1 assignment statement and the trick is done. For example I have the following statements in my .bashrc:
Code:

#
#    ┌─  is  u250C + u2500
#    └─  is  u2514 + u2500
#    •    is  u26AB
#    ▪    is  u25AA
#    ▸    is  u25B8
#
G='\033[0;30m' # black
N='\033[0;32m' # green
C='\033[0;36m' # cyan
R='\033[0;31m' # red
W='\033[0m'    # default
B='\033[0;37m' # white
if tty | grep -q tty
then
  export PS1="\[$W\]┌─[\[$N\]\u\[$W\]@\[$C\]\h\[$W\]]-[\[$R\]\W\[$W\]]\n└─• \[$W\]"
else
  export PS1="\[$G\]┌─[\[$N\]\u\[$G\]@\[$C\]\h\[$G\]]-[\[$R\]\W\[$G\]]\n└─• \[$W\]"
fi

The tty part checks if I am in a Virtual Console (text mode) or in a Pseudo Terminal and change the colours accordingly, since my VC has a black background whereas my terminal is white. The prompt appears like this:
Code:

┌─[colucix@ocean-4]-[~]
└─•


soundie 09-30-2011 04:50 AM

Quote:

Originally Posted by colucix (Post 4486288)
You can customize your prompt with symbols from the Unicode table. To generate Unicode characters you have to use a terminal or an editor that support them. To type them, press simultaneously Ctrl-Shft-U, then type the code and press enter. The unicode character will appear, provided you have a font from which that character is available. Gnome-terminal and Firefox support this method.

In alternative you can open a VIM session, press I to enter in insert mode, then press Ctrl-V, then U, then the code and the character appears. You can copy and paste them in your PS1 assignment statement and the trick is done. For example I have the following statements in my .bashrc:
Code:

#
#    ┌─  is  u250C + u2500
#    └─  is  u2514 + u2500
#    •    is  u26AB
#    ▪    is  u25AA
#    ▸    is  u25B8
#
G='\033[0;30m' # black
N='\033[0;32m' # green
C='\033[0;36m' # cyan
R='\033[0;31m' # red
W='\033[0m'    # default
B='\033[0;37m' # white
if tty | grep -q tty
then
  export PS1="\[$W\]┌─[\[$N\]\u\[$W\]@\[$C\]\h\[$W\]]-[\[$R\]\W\[$W\]]\n└─• \[$W\]"
else
  export PS1="\[$G\]┌─[\[$N\]\u\[$G\]@\[$C\]\h\[$G\]]-[\[$R\]\W\[$G\]]\n└─• \[$W\]"
fi

The tty part checks if I am in a Virtual Console (text mode) or in a Pseudo Terminal and change the colours accordingly, since my VC has a black background whereas my terminal is white. The prompt appears like this:
Code:

┌─[colucix@ocean-4]-[~]
└─•



Thanks colucix, this is what I'm looking for!! :)
Have a nice day!

colucix 09-30-2011 05:02 AM

You're welcome! :)


All times are GMT -5. The time now is 07:50 PM.