View previous topic :: View next topic |
Author |
Message |
ruth Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
Joined: 07 Sep 2003 Posts: 640 Location: M / AN / BY / GER
|
Posted: Thu Sep 09, 2004 12:02 pm Post subject: bash prompt |
|
|
hallihallo,
heute möchte ich eigenlich nur meinen bash prompt vorstellen.
manchmal fällt es mir schwer, in einem wust von offenen shells den überblick zu behalten.
deshalb habe ich die folgenden dateien angelegt:
~/.bash_profile
Code: |
[ -f "$HOME/.bashrc" ] && . $HOME/.bashrc
|
die dürfte jeder noch so (ähnlich) haben
und dann noch:
~/.bashrc
Code: |
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion
alias ls='ls --color=auto'
alias nano="nano -w"
function set_prompt {
local BLACK="\[\033[0;30m\]"
local BLUE="\[\033[0;34m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local RED="\[\033[0;31m\]"
local PURPLE="\[\033[0;35m\]"
local BROWN="\[\033[0;33m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local DARK_GRAY="\[\033[1;30m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local LIGHT_CYAN="\[\033[1;36m\]"
local LIGHT_RED="\[\033[1;31m\]"
local LIGHT_PURPLE="\[\033[1;35m\]"
local YELLOW="\[\033[1;33m\]"
local WHITE="\[\033[1;37m\]"
local NO_COLOUR="\[\033[0m\]"
if [ "$HOSTNAME" = "leela" ]; then
local HOST_COLOUR=$GREEN
elif [ "$HOSTNAME" = "h5877" ]; then
local HOST_COLOUR=$LIGHT_RED
fi
if [ `mount | grep 'noexec' | wc -l` -gt 0 ]; then
mnt_tmp="${WHITE}[tmp:${LIGHT_GREEN}noexec${WHITE}]${NO_COLOUR}"
else
mnt_tmp="${WHITE}[tmp:${LIGHT_RED}exec${WHITE}]${NO_COLOUR}"
fi
if [ $UID -eq 0 ]; then
local user="$WHITE[$LIGHT_RED\u$WHITE@$HOST_COLOUR\h$WHITE]"
else
local user="$WHITE[$LIGHT_GREEN\u$WHITE@$HOST_COLOUR\h$WHITE]"
fi
PS1="${user}\
$mnt_tmp\$NO_COLOUR\
$WHITE($YELLOW\w$WHITE) \\$ $NO_COLOUR"
}
export PROMPT_COMMAND=set_prompt
|
interessant hier ist der teil:
Code: |
if [ "$HOSTNAME" = "leela" ]; then
local HOST_COLOUR=$GREEN
[more_hosts_here]
elif [ "$HOSTNAME" = "h5694" ]; then
local HOST_COLOUR=$LIGHT_RED
[more_hosts_here]
fi
|
wie man sieht, heisst meine lokale maschine leela
einer meiner _wichtigen_ rechner heisst h5694, was das für eine maschine ist, das kann man sich denken...
nun, was ist der effekt?
also, als root auf meiner lokalen maschine sieht das dann so aus:
[root@leela][tmp:exec](~) #
als root auf der grossen maschine so:
[root@h5694][tmp:noexec](~) #
ausserdem wird root immer in rot dargestellt, ein unprivilegierter nutzer in grün
die relativ unwichtigen, weil lokalen maschinen in grün, und die wichtigen, weil bloss nichts verkehrt machen darf maschinen in rot
desweiteren wird der mount-zustand (exec || noexec) des /tmp dateisystems dargestellt; dass man nicht vergisst vor dem ausloggen das /tmp wieder auf grün zu setzen...
die ürsprüngliche version dieses prompts hat mir mal ein kumpel per mail geschickt; ich hab das dann für mich so angepasst...
hoffe, das ist für ein paar leute von nutzen...
gruss
rootshell _________________ "The compiler has tried twice to abort and cannot do so; therefore, compilation will now terminate."
-- IBM PL/I (F) error manual |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Minox Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1721757979407e4484c71b6.jpg)
Joined: 12 Apr 2004 Posts: 188 Location: Germany / Munich
|
Posted: Thu Sep 09, 2004 12:41 pm Post subject: |
|
|
Super grosses Merci
Jetzt brauche ich mir da nicht mehr den Kopf zerbrechen wegen. Ich passe das farblich auch noch aweng an, denn bei mir hat das einen Stich von Italien und ich stehe mehr auf Spanien
Auf jeden Fall: Danke rootshell
MfG _________________
proud to be 100% M$ free ![Exclamation :!:](images/smiles/icon_exclaim.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Macrobiotus Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/gallery/Futurama/cartoon_futurama_brainslug.gif)
Joined: 06 Oct 2002 Posts: 230
|
Posted: Thu Sep 09, 2004 5:26 pm Post subject: |
|
|
Schöne Idee (für Leute die sich mit sowas (buntem) nie beschäftigt haben.
Sieht das eigentlich bei euch auch so aus?
Code: |
BROWN='\[\033[0;33m\]'
CYAN='\[\033[0;36m\]'
DARK_GRAY='\[\033[1;30m\]'
GREEN='\[\033[0;32m\]'
HOST_COLOUR='\[\033[1;31m\]'
LIGHT_BLUE='\[\033[1;34m\]'
LIGHT_CYAN='\[\033[1;36m\]'
LIGHT_GRAY='\[\033[0;37m\]'
LIGHT_GREEN='\[\033[1;32m\]'
LIGHT_PURPLE='\[\033[1;35m\]'
LIGHT_RED='\[\033[1;31m\]'
NO_COLOUR='\[\033[0m\]'
PURPLE='\[\033[0;35m\]'
RED='\[\033[0;31m\]'
WHITE='\[\033[1;37m\]'
YELLOW='\[\033[1;33m\]'
[macro@biotus][tmp:exec](~/Bilder/icons) $ ls
audacity.png firefox.svg Nautilus2.png Splash-EvolvingTux.png
beep4.png gimp.svg Nautilus.png web-browser1.svg
blender.png gnome-gimp.svg ooo_gulls.svg web-browser.svg
blender.svg gnome-terminal.svg OpenOffice2.png xmms-rmckenzie.png
cr32-app-kile.png gthumb.svg OpenOffice.png xmms.svg
Digital-Camera1.png Mozilla-Mail_alt.png Printer.png
BROWN='\[\033[0;33m\]'
CYAN='\[\033[0;36m\]'
DARK_GRAY='\[\033[1;30m\]'
GREEN='\[\033[0;32m\]'
HOST_COLOUR='\[\033[1;31m\]'
LIGHT_BLUE='\[\033[1;34m\]'
LIGHT_CYAN='\[\033[1;36m\]'
LIGHT_GRAY='\[\033[0;37m\]'
LIGHT_GREEN='\[\033[1;32m\]'
LIGHT_PURPLE='\[\033[1;35m\]'
LIGHT_RED='\[\033[1;31m\]'
NO_COLOUR='\[\033[0m\]'
PURPLE='\[\033[0;35m\]'
RED='\[\033[0;31m\]'
WHITE='\[\033[1;37m\]'
YELLOW='\[\033[1;33m\]'
[macro@biotus][tmp:exec](~/Bilder/icons) $ |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
7maestro7 Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/83043229941408481af59d.jpg)
Joined: 10 Aug 2004 Posts: 149 Location: Baden ohne Württemberg
|
Posted: Thu Sep 09, 2004 5:34 pm Post subject: |
|
|
was hat es denn mit dem tmp:noexec auf sich....
bzw mit dem mounten von /tmp ich hab da keine Ahnung...
könnte mir jmd mal einen link geben was das soll oder mir das in kurzen worten erklären nur falls jmd langweilig iss...
danke
maestro |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Minox Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1721757979407e4484c71b6.jpg)
Joined: 12 Apr 2004 Posts: 188 Location: Germany / Munich
|
Posted: Thu Sep 09, 2004 7:22 pm Post subject: |
|
|
Ich hab das auch wieder raus genommen mit dem tmp:exec/noexec. Zumindest grept das Script aus der mount list, datei systeme auf denen dateien nicht ausgeführt werden dürfen. Aber da im Befehl "mount" ohne parameter verwendet wird würde er jedes mal wenn ein einziges fs im system das flag noexec hat auf der gesamten shell tmp:noexec anzeigen. Also, entweder ein wenig optimieren oder rausnehmen ![Wink ;)](images/smiles/icon_wink.gif) _________________
proud to be 100% M$ free ![Exclamation :!:](images/smiles/icon_exclaim.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
7maestro7 Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/83043229941408481af59d.jpg)
Joined: 10 Aug 2004 Posts: 149 Location: Baden ohne Württemberg
|
Posted: Thu Sep 09, 2004 7:25 pm Post subject: |
|
|
ja rausgenommen hab ichs auch ich wollte nur wissen wieso man tmp auf exec/noexec setzen sollte... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Deever Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/d9a2e9133d29eda9e7305.gif)
Joined: 06 Jul 2002 Posts: 1354 Location: Zürich / Switzerland
|
Posted: Thu Sep 09, 2004 8:09 pm Post subject: |
|
|
Alternativ zu alledem kann man screen verwenden und den Hostnamen in der Statuszeile anzeigen. Dann weiß man auch bei anderen Programmen, auf welchem Rechner man gerade arbeitet!
Gruß && HTH!
/dev |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Minox Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1721757979407e4484c71b6.jpg)
Joined: 12 Apr 2004 Posts: 188 Location: Germany / Munich
|
Posted: Thu Sep 09, 2004 8:23 pm Post subject: |
|
|
Macrobiotus wrote: | Schöne Idee (für Leute die sich mit sowas (buntem) nie beschäftigt haben.
Sieht das eigentlich bei euch auch so aus? |
Nein eigentlich nicht. Wirst wohl was in der bashrc falsch eingetragen haben. Oder beim copy/paste was kaputt gegangen. _________________
proud to be 100% M$ free ![Exclamation :!:](images/smiles/icon_exclaim.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Macrobiotus Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/gallery/Futurama/cartoon_futurama_brainslug.gif)
Joined: 06 Oct 2002 Posts: 230
|
Posted: Thu Sep 09, 2004 9:24 pm Post subject: |
|
|
Quote: | Wirst wohl was in der bashrc falsch eingetragen haben. Oder beim copy/paste was kaputt gegangen.
|
So wars, danke ![Rolling Eyes :roll:](images/smiles/icon_rolleyes.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Pamino Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/gallery/Futurama/cartoon_futurama_tiny_tim.gif)
Joined: 07 Apr 2004 Posts: 281 Location: 127.0.0.1
|
Posted: Thu Sep 09, 2004 9:52 pm Post subject: |
|
|
Kann mal bitte jemand seine .bashrc ohne das exec posten? Ich mach da irgendwas falsch
Und gibt es eine Möglichkeit statt dem Pfad einfach nur den Ordnernamen in dem man sich befindet anzeigen zu lassen? Wird sonst manchmal zu lang.... den Kompletten Pfad hatte ich sonst immer in der titelleiste und in .bashrc stand nur source /etc/profile. Wie kann ich wieder den Pfad in der Leiste anzeigen lassen?
Edit: Das temp hab ich doch entfernen können ^^
Edit2: Wenn ich das hinzufüge....
if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ]
then
if [ "$TERM" = 'xterm' ]
then
PROMPT_COMMAND='echo -ne "\033]0; ${PWD}\007"'
fi
fi
...dann hab ich in xterm wieder meine alte Titelleiste. Fehlt nur noch der Ordername statt Pfad zur Perfektion....da hab ich aber leider keine idee |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Minox Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/1721757979407e4484c71b6.jpg)
Joined: 12 Apr 2004 Posts: 188 Location: Germany / Munich
|
Posted: Thu Sep 09, 2004 10:14 pm Post subject: |
|
|
Pamino wrote: | Kann mal bitte jemand seine .bashrc ohne das exec posten? Ich mach da irgendwas falsch ![Very Happy :D](images/smiles/icon_biggrin.gif) |
Lösche einfach den Teil:
Code: | if [ `mount | grep 'noexec' | wc -l` -gt 0 ]; then
mnt_tmp="${WHITE}[tmp:${LIGHT_GREEN}noexec${WHITE}]${NO_COLOUR}"
else
mnt_tmp="${WHITE}[tmp:${LIGHT_RED}exec${WHITE}]${NO_COLOUR}"
fi |
MfG _________________
proud to be 100% M$ free ![Exclamation :!:](images/smiles/icon_exclaim.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
marc Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 13 Jan 2003 Posts: 290
|
Posted: Thu Sep 09, 2004 10:15 pm Post subject: |
|
|
Code: | export PS1="\033[1;34m\]\u@\h \033[00m\] \t \033[32m\]\w \033[1;35m\]\$(/bin/ls -1a | /usr/bin/wc -l | /bin/sed 's: ::g') Einträge \033[00m\]\n\$ \033[00m\]"
alias ls="ls --color"
alias dir="dir --color"
alias su="su -" |
Für root habe ich die in /etc/profile geändert. root soll ja schliesslich "erkannt" werden. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
sirro Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/156577888654a6624bb6682.png)
Joined: 20 Jul 2003 Posts: 1472 Location: aachen.nrw.de.eu
|
Posted: Fri Sep 10, 2004 7:08 am Post subject: |
|
|
7maestro7 wrote: | ja rausgenommen hab ichs auch ich wollte nur wissen wieso man tmp auf exec/noexec setzen sollte... |
Vorteil: ein (großer?) Teil Exploits laufen ins leere, da diese exec voraussetzen
Nachteil: Manche "normalen" Installer tuns auch nichtmehr. Wer nur mit portage arbeitet sollte damit kein Problem haben ![Wink ;-)](images/smiles/icon_wink.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
toskala Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/15247838633ff9618bdf5b6.gif)
Joined: 14 Dec 2002 Posts: 2080 Location: hamburg, germany
|
Posted: Tue Sep 28, 2004 7:29 am Post subject: |
|
|
oha, nice one, rootshell
mal kucken wie ich das verwurschtel ![Wink ;)](images/smiles/icon_wink.gif) _________________ adopt an unanswered post
erst denken, dann posten |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
equinox0r l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/15747380254242c3efe10f0.jpg)
Joined: 18 Feb 2004 Posts: 614
|
Posted: Wed Sep 29, 2004 8:11 am Post subject: |
|
|
ich hab bei mir mal geschaut ich hab die standard .screenrc etwas modifiziert damit sie auch meinen anforderungen gerecht wird
das funktioniert auch alles soweit nur dass der prompt innerhalb vom screen ziemlich zerschossen ist.
Vorher-Nachher: Code: | [8:58:48]}[equinox@dude.zion ]
[/data/home/equinox] $ screen
\[\033[1;32m\][\[\033[1;37m\]\t\[\033[1;32m\]]}[\[\033[1;37m\]\u\[\033[1;32m\]@\[\033[1;37m\]dude.zion \[\033[1;32m\]]\n\[\033[1;32m\][\[\033[1;37m\]\w\[\033[1;32m\]]\[\033[00m\] $ |
in meiner ~/.screenrc steht: Code: | hardstatus alwayslastline "%{wk}%H %{wk}%?%-Lw%?%{wb}%n*%f %t%?(%u)%?%{wk}%?%+Lw%? %{dk}%= %{ck}%Y-%m-%d %{ck}%c" |
und schlussendlich meine .bashrc (der relevante teil): Code: | host_name=`hostname -f`
PROMPT="${mask}[${usercol}\t${mask}]}\
[${white}\u${mask}@${white}${host_name}${mask}]\n\
${mask}[${white}\w${mask}]\
${normal} \$ "
test -z "$PROFILEREAD" && . /etc/profile
if [ "$TERM" == "screen" ]; then
SCREEN_AUTO=`echo -n -e "\033k\033\134"`
PS1='$PROMPT $SCREEN_AUTO'
else
PS1=$PROMPT
fi
export DISPLAY LESS PS1 |
wie krieg ich das richtig hin? _________________ AMD 2400+ XP | 1024 MB RAM | ATI Radeon 9600Pro
Gentoo Base System version 1.4.16 | Portage 2.0.51.19 | 2.6.11-gentoo-r9 Kernel |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
appro Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/2037644093415af55a334a0.png)
Joined: 21 Jul 2003 Posts: 144 Location: Germany/Rosenheim
|
Posted: Wed Sep 29, 2004 5:39 pm Post subject: Bash-Prompt |
|
|
Ich denke mal du willst aus Code: | PS1='$PROMPT $SCREEN_AUTO' | ein Code: | PS1="$PROMPT $SCREEN_AUTO" | machen :)
Ist die Uhrzeit im Prompt nicht sinnlos, wenn du sie schon im screen unten rechts hast? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Lukas_Drude n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 24 Sep 2006 Posts: 21
|
Posted: Mon Oct 02, 2006 9:52 pm Post subject: |
|
|
Ich habe mal die Anweisungen befolgt, die abgewandelte Promt funktioniert auch in der Konsole (STRG + F1 bis F4), aber leider weder mit xterm noch mit aterm oder Eterm. Wenn ich dann aber "export PROMPT_COMMAND=set_prompt" eingebe, dann funktioniert alles so, wie es sein soll.
Jetzt würde mir einfallen, dass die Konsolen beim starten gleich den Befehl mit ausführen sollen (mit alias?), aber das ist sicher nicht die angedachte Lösung.
Sicherheitshalber hab ich die http://crs-abi-2006.de/multi/.bashrc nochmal hochgeladen. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Lukas_Drude n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 24 Sep 2006 Posts: 21
|
Posted: Mon Oct 09, 2006 10:02 pm Post subject: |
|
|
Die Frage hat sich geklärt. Alles steht jetzt in /etc/bash/bashrc und /etc/profile sourced ersteres, so ist alles abgedeckt. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Moorenkopf Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 18 Apr 2004 Posts: 189 Location: NRW
|
Posted: Mon Oct 09, 2006 10:38 pm Post subject: Re: bash prompt |
|
|
ruth wrote: | Code: |
alias ls='ls --color=auto'
alias nano="nano -w"
|
|
Du könntest statt dem nano-Alias auch einfach die Zeile set nowrap aus der /etc/nanorc auskommentieren. </klugscheiß>
Ansonsten, nette Idee ![Smile :)](images/smiles/icon_smile.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|