Archiv verlassen und diese Seite im Standarddesign anzeigen : Schöne Bunte Shell
da das thema nicht hierher verschoben wurde hier nochmal:
Ich hab einen Text geschrieben, wie man seine Shell schön bunt machen kann.
Ich glaub Knoppix nutzt das auch bei seinem Shell Prompt.
Ihr findet ihn hier:
http://www.ngolde.de/texte/shell_colors.html
mir fällt gerade noch ein, ich suche noch jemanden, der den text ins englische übersetzen will/kann.
hat jemand von euch lust/zeit dazu?
wenn ja hier posten oder mail an:
nico at ngolde dot de
1. Generally
Colored highlights in shells make the shell
individual and good readable.
In this HOWTO I'll correlate with the shell 'bash'.
The escape-sequenzes can change depending on the used
terminal. I used an ANSI-terminal for this HOWTO.
1.1 Configuration of bash
The central config-file of bash, which is also used for
color configuration is ~/.bashrc or the global config-file
/etc/bashrc.
The settings for the shell look&feel are set in the PS1 variable
in the bashrc.
Normally it should look like this:
~/.bashrc: PS1="\s-\v\$ "
The \s stands for the name of the shell and the -\v for the version.
This prompt is finished with an $-
Actually that looks a little boring, so you can use this string
instead:
~/.bashrc: PS1="\u@\h \w \$ "
This stands for user@host working_directory $
That's the normal shell-prompt, most linux users are familiar with.
1.2 Escape sequences
Now we use escape-sequences to give this prompt a personal note
with different colors. An escape-sequence is a control-sign, that
leads the shell to do something.
Normally an escape-sequence starts with ^[
Alternative you can use \033
While using the shell itself, you can cause an escape-sequence start
by pressing Ctrl+v and Esc.
1.3 Using shell colors
I'll explain the shell-colors with an example propmt.
~/.bashrc: PS1="\033[0;32;40m\u@\h:\w\$ "
This will show the complete promt in green.
\033 starts the escape-sequence, [ opens color specification.
The following 0 means a normal showing, I'll explain other
capabilities soon.
Now we choose foreground-color (in this case 32 for green).
the background-color 40 means black.
If you don't want the text the users types in a different color than
the prompt itself, you finish with the escape-sequence \033[0m
This is the default-setting for the shell color.
For both foreground and background are 8 colors possible:
foreground / background:
30/40: black
31/41: red
32/42: green
33/43: yellow
34/44: blue
35/45: magenta
36/46: cyan
37/47: white
Another example:
~/.bashrc PS1="\033[0;37;44m\u@\033[0;32;43m\h:\033[0;33;41m\w$\033[0m"
The best is, you test these setting with export PS1="string" so you
can write them back to bashrc.
At the moment my prompt looks like this:
~/.bashrc PS1="\033[1;34;40m[\033[1;31;40m\u@\h:\w\033[1;34;40m] \033[1;37;40m\$\033[0;37;40m "
1.4 Font-settings
As mentioned above, the 0 directly after the first escape-sequence means
normal showing for the shell font. At this position you can also set
the following numbers (meaning):
0 (default)
1 (thick)
22 (not thick)
4 (underlined)
24 (not underlined)
5 (blinking)
25 (not blinking)
7 (inverted)
27 (not inverted)
With this little shell script you can see the color combinations:
#!/bin/sh
# Nico Golde <nico@ngolde.de>
# Homepage: http://www.ngolde.de
# Letzte Änderung: Mon Feb 16 16:24:41 CET 2004
################################################
for attr in 0 1 4 5 7 ; do
echo "----------------------------------------------------------------"
printf "ESC[%s;Vordergrund;Hintergrundm - \n" $attr
for fore in 30 31 32 33 34 35 36 37; do
for back in 40 41 42 43 44 45 46 47; do
printf '\033[%s;%s;%sm %02s;%02s ' $attr $fore $back $fore $back
done
printf '\n'
done
printf '\033[0m'
done
2. Other implementations
The ability of the shell is not only usefull for getting a nice
prompt, you can also use it for console-programs.
Normaly you have to use libraries like slang or ncurses, which let
the binary grow extremly.
Though ncurses has the advantage that it's terminal independent.
2.1 Example in C
Hello World in green:
#include <stdio.h>
int main(void){
const char *const green = "\033[0;40;32m";
const char *const normal = "\033[0m";
printf("%sHello World%s\n", green, normal);
return 0;
}
Another usefull escape-sequence is printf("\033[2J");
It has the same effect like system(clear);
though you can abstain from using the unistd.h header.
With printf("\033[1K"); you can erase a line.
3. Feedback
Please mail Feedback, bugs, etc. to nico@ngolde.de.
Have fun...
------------------------------------
Kann aber nicht garantieren, dass alles richtig übersetzt ist, hab mein bestes versucht...
ThorstenHirsch
26.02.04, 20:17
Wie wär's mit nem Screenshot?
Screenshot wovon?
Fuer alle, die ein bisschen tiefer gehen wollen, koennen sich auch mal die restlichen Bash-HowTos
angucken: http://www.tldp.org/HOWTO/HOWTO-INDEX/os.html#OSSHELL
'cuda
ThorstenHirsch
26.02.04, 20:39
Na ein Screenshot von der bunten Konsole!
Wenn ich wissen will ob sich sowas lohnt les ich mir doch nicht erst alles durch nur um nach 10min festzustellen, dass es das gleiche is, wie das was ich schon hab...oder nur unwesentlich mehr. Da schau ich mir lieber nen Screenshot an und weiß innerhalb von Sekunden bescheid ob's mich interessiert oder nich.
hab mir mal die arbeit gemacht, da man nur eine datei anhängen kann verteil ich das auf mehrere posts...
------------------
another example
das wohl interessanteste dürfte das cript sein:
ich hab mir auch mal ne eigene farbgebung gebastelt:
da das thema nicht hierher verschoben wurde hier nochmal:
Ich hab einen Text geschrieben, wie man seine Shell schön bunt machen kann.
Ich glaub Knoppix nutzt das auch bei seinem Shell Prompt.
Ihr findet ihn hier:
http://www.ngolde.de/texte/shell_colors.html
Der Link funktioniert leider nicht!
Da hat aber wieder einer die Grubenlampe ausgepackt :ugly:
Ja und? Ich möchte halt eine "schöne bunte shell" ^^
Hi
Ja und? Ich möchte halt eine "schöne bunte shell" ^^
Nun canuma hat ja aber im Post #3 ja eine Übersetzung davon ins Englische gemacht ;)
MfG carnil
Das Hab ich mal ausprobiert, aber es funktioniert nicht. Mein English is auch nicht nicht gerade so das beste!
//EDIT: Hat sich erledigt! Es funzt! Hatte da was falsch verstanden =)
Zitat von ollonois
Da hat aber wieder einer die Grubenlampe ausgepackt
Das beweist wenigstens das ich die Suchfunktion nutze oder ;)
Wieso werden bei mir änderungen in der
.bashrc
Datei ignoriert?
Wenn ich in der Shell direkt PS1="\033[1;34;40m[\033[1;31;40m\u@\h:\w\033[1;34;40m] \033[1;37;40m\$\033[0;37;40m " eingebe funktionierts, aber auch nur bis ich mich neu einlogge, dann ist alles wieder wie vorher.
Bei root funktioniert das, aber bei den Users nicht!
Der Link funktioniert leider nicht!
sorry, ich habe gerade meine website ein bisschen umstrukturiert.
geh mal auf:
http://www.ngolde.de/papers.html
da ist der verlinkt.
sorry avuton
Thx das hab ich inzwischen schon über Google gefunden. Aber leider funzt es nur wenn ich die Befehle direkt in der Shell eingebe. Wenn ich aber die .bashrc bearbeite funktioniert es nicht. Wird nicht angenommen, zumindest nicht als User. Als root (/root/.bashrc) ja! Wieso bei den Usern (/home/user/.bashrc) nicht?
//EDIT: Hat sich erledigt. Habe in der .bash_profile folgendes auskommentiert:
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Jetzt wird es angenommen.
HirschHeisseIch
28.09.04, 15:30
Wieso werden bei mir änderungen in der
.bashrc
Datei ignoriert?
Wenn ich in der Shell direkt PS1="\033[1;34;40m[\033[1;31;40m\u@\h:\w\033[1;34;40m] \033[1;37;40m\$\033[0;37;40m " eingebe funktionierts, aber auch nur bis ich mich neu einlogge, dann ist alles wieder wie vorher.
Bei root funktioniert das, aber bei den Users nicht!
Könnte daran liegen, dass die ~/.bashrc normalerweise nur von nicht-loginshells abgearbeitet wird.
Für loginshells ist halt die ~/.bash_profile ;)
sonst schreib den ps1 prompt direkt in deine /etc/profile
Powered by vBulletin® Version 4.2.5 Copyright ©2024 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.