Anzeige:
Seite 1 von 2 12 LetzteLetzte
Ergebnis 1 bis 15 von 20

Thema: Schöne Bunte Shell

  1. #1
    Registrierter Benutzer
    Registriert seit
    Aug 2002
    Beiträge
    354

    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

  2. #2
    Registrierter Benutzer
    Registriert seit
    Aug 2002
    Beiträge
    354
    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

  3. #3
    Registrierter Benutzer
    Registriert seit
    Feb 2004
    Beiträge
    18
    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...
    und eine stimme sagte mir :"laechle und sei froh, es könnte schlimmer kommen!"
    und ich laechelte und ich war froh... und es kam schlimmer....

  4. #4
    Registrierter Benutzer Avatar von ThorstenHirsch
    Registriert seit
    Nov 2002
    Beiträge
    6.556
    Wie wär's mit nem Screenshot?
    ¡Nuestro amigo... el Computador!

  5. #5
    Shot a man in Reno Avatar von HEMIcuda
    Registriert seit
    Jun 2003
    Ort
    Am Rande des Wahnsinns
    Beiträge
    5.481
    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

  6. #6
    Registrierter Benutzer Avatar von ThorstenHirsch
    Registriert seit
    Nov 2002
    Beiträge
    6.556
    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.
    ¡Nuestro amigo... el Computador!

  7. #7
    Registrierter Benutzer
    Registriert seit
    Feb 2004
    Beiträge
    18
    hab mir mal die arbeit gemacht, da man nur eine datei anhängen kann verteil ich das auf mehrere posts...
    ------------------
    another example
    und eine stimme sagte mir :"laechle und sei froh, es könnte schlimmer kommen!"
    und ich laechelte und ich war froh... und es kam schlimmer....

  8. #8
    Registrierter Benutzer
    Registriert seit
    Feb 2004
    Beiträge
    18
    nicos_shell
    und eine stimme sagte mir :"laechle und sei froh, es könnte schlimmer kommen!"
    und ich laechelte und ich war froh... und es kam schlimmer....

  9. #9
    Registrierter Benutzer
    Registriert seit
    Feb 2004
    Beiträge
    18
    das wohl interessanteste dürfte das cript sein:
    und eine stimme sagte mir :"laechle und sei froh, es könnte schlimmer kommen!"
    und ich laechelte und ich war froh... und es kam schlimmer....

  10. #10
    Registrierter Benutzer
    Registriert seit
    Feb 2004
    Beiträge
    18
    ich hab mir auch mal ne eigene farbgebung gebastelt:
    und eine stimme sagte mir :"laechle und sei froh, es könnte schlimmer kommen!"
    und ich laechelte und ich war froh... und es kam schlimmer....

  11. #11
    Registrierter Benutzer Avatar von DiWoWo
    Registriert seit
    Dec 2002
    Ort
    Worms
    Beiträge
    272
    Zitat Zitat von avuton
    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!
    ------------------------------------------------
    *VIVA*LOS*TIOZ*

  12. #12
    anders Denkender Avatar von ollonois
    Registriert seit
    Jul 2002
    Ort
    Bochum
    Beiträge
    2.382
    Da hat aber wieder einer die Grubenlampe ausgepackt
    Samsung NC10: Gentoo Linux 2.6.39 | i3 4.0.2

  13. #13
    Registrierter Benutzer Avatar von DiWoWo
    Registriert seit
    Dec 2002
    Ort
    Worms
    Beiträge
    272
    Ja und? Ich möchte halt eine "schöne bunte shell" ^^
    ------------------------------------------------
    *VIVA*LOS*TIOZ*

  14. #14
    Mod. Tipps und Tricks Avatar von carnil
    Registriert seit
    Jan 2004
    Ort
    Zürich
    Beiträge
    6.215
    Hi
    Zitat Zitat von DiWoWo
    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

  15. #15
    Registrierter Benutzer Avatar von DiWoWo
    Registriert seit
    Dec 2002
    Ort
    Worms
    Beiträge
    272
    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
    Geändert von DiWoWo (28.09.04 um 14:29 Uhr)
    ------------------------------------------------
    *VIVA*LOS*TIOZ*

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •