Durch eine Verkettung blöder Umstände ist mir meine bashrc abhanden gekommen - könnte vielleicht jemand die Gentoo-Standard-bashrc posten (besonders die Farbkodierung für root etc. finde ich allerliebst)
Gruß und danke im Voraus, Hauke

Code: Select all
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
Code: Select all
perl -WTe '($")=$/;print qq(@{[reverse('0'..'100')]}$/BOOM!$/);'Code: Select all
stephan@unimatrix ~ :) $ cat /etc/skel/.bashrc
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
# Change the window title of X terminals
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
Code: Select all
perl -WTe '($")=$/;print qq(@{[reverse('0'..'100')]}$/BOOM!$/);'Code: Select all
$ cat /etc/skel/.bashrc
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# Put your fun stuff here.

Code: Select all
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# Put your fun stuff here.Code: Select all
# /etc/skel/.bashrc:
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if [[ -f ~/.dir_colors ]]; then
eval `dircolors -b ~/.dir_colors`
else
eval `dircolors -b /etc/DIR_COLORS`
fi
# Change the window title of X terminals
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
shopt -s histappend
PROMPT_COMMAND='history -a'

Code: Select all
# Change the window title of X terminals
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac Vermutlich hast Du die neuere, da das meiste bereits in /etc/bash/bashrc enthalten ist und daher nicht "doppelt" auch noch in ~/.bashrc zu sein braucht - ist vor einiger Zeit als Bug gemeldet worden. @MaxSteel: Natürlich wird die ~/.bashrc bei einem Update nicht automatisch von /etc/skel übernommen.dek wrote:Oooook, einer von uns beiden hat eine veraltete Version. :)
Das ist nicht korrekt. Das PROMPT_COMMAND wird jedes mal neu ausgeführt. Bei PS1=$(...) wird der Befehl nur einmal ausgeführt (nämlich wenn die Variable belegt wird) - und erzielt damit nicht das korrekte ergebnis. (in dem Fall hier schon, wenn man die Prompt-Platzhalter (%h, %u, etc) benutzt)mv wrote:Zumal es ja ein PS1=$(...) ebenso tutok wrote:Aber ein PROMPT_COMMAND=... sollte meiner Meinung nach nicht als Standard in eine bashrc.
Code: Select all
necoro@Devoty ~ $ PROMPT_COMMAND="echo hallo"
hallo
necoro@Devoty ~ $ echo muh
muh
hallo
necoro@Devoty ~ $ cd ..
hallo
necoro@Devoty home $ unset PROMPT_COMMAND
necoro@Devoty home $ PS1='$(echo "hallo $PWD ")'
hallo /home cd necoro
hallo /home/necoro Code: Select all
PS1='$(echo -ne "\033]0;Mein Titel\007")'$PS1Code: Select all
ESCAPE=$'\e'
BLACK="${ESCAPE}[0;30m"
BLUE="${ESCAPE}[0;34m"
GREEN="${ESCAPE}[0;32m"
CYAN="${ESCAPE}[0;36m"
RED="${ESCAPE}[0;31m"
PURPLE="${ESCAPE}[0;35m"
BROWN="${ESCAPE}[0;33m"
LIGHT_GRAY="${ESCAPE}[0;37m"
DARK_GRAY="${ESCAPE}[1;30m"
LIGHTBLUE="${ESCAPE}[1;34m"
LIGHTGREEN="${ESCAPE}[1;32m"
LIGHTCYAN="${ESCAPE}[1;36m"
LIGHTRED="${ESCAPE}[1;31m"
LIGHTPURPLE="${ESCAPE}[1;35m"
YELLOW="${ESCAPE}[1;33m"
WHITE="${ESCAPE}[1;37m"
NORMCOL="${ESCAPE}[0m"
set_prompt() {
local STATUS='' DISTRI='' SEP=':' PLAIN PLAINC DIR DIRC
local STARTXSTATUS="${ESCAPE}]0;"
local ENDXSTATUS=$'\007'
local STARTSSTATUS="${ESCAPE}k"
local ENDSSTATUS="${ESCAPE}"'\\'
local C_USR='' C_AT='' C_HST='' C_DIR='' C_DT='' C_HSH='' C_SEP='' C_END=''
local H_USR='' H_AT='' H_HST='' H_DIR='' H_DT='' H_HSH='' H_SEP='' H_END=''
local C_EXT='' C_EXS=''
local H_EXT='' H_EXS=''
local EXT='' PEXT='' PCEXT='' DOTS PDOTS
local COLOR=: SCREEN=: XTERM=: CUT=: ZSH=false EX=false
local OPEN='\[' CLOSE='\]' EDIR='\w' EUSER='\u' EHST='\h' EPROMPT='\$'
local D1 D2 D3 ARG
local OPTIND=1
while getopts 'CSXle?hH' ARG
do case "${ARG}" in
C) COLOR=false;;
S) SCREEN=false;;
X) XTERM=false;;
l) CUT=false;;
e) EX=:;;
*) echo "Usage: set_prompt [options]
-C No colorized prompt
-S No screen hardstatus
-X No xterm hardstatus
-l Long path (i.e. no path shortening)
-e Extended prompt"
return 1;;
esac
done
if [ -n "${DISTRITEXT}" ]
then DISTRI="(${DISTRITEXT})"
SEP="${DISTRI}"
fi
[ -z "${BASH}" ] && ZSH=:
if ${ZSH}
then OPEN='%{'; CLOSE='%}'; EDIR='%~' EUSER='%n'; EHST='%m'
EPROMPT='%(!.&.%%)'; ENDSSTATUS="${ESCAPE}"'\'
fi
if ${COLOR}
then [ -n "${UID}" ] || UID="$(id -u)"
[ -n "${GID}" ] || GID="$(id -g)"
C_AT="${CYAN}"
C_HST="${GREEN}"
C_DIR="${LIGHTGREEN}"
C_DT="${BLUE}"
C_HSH="${YELLOW}"
C_SEP="${CYAN}"
C_END="${NORMCOL}"
C_EXT="${LIGHTRED}"
C_EXS="${BROWN}"
[ -n "${SSH_TTY}${SSH_CONNECTION}" ] && C_HST="${LIGHTRED}"
[ "${DISTRITEXTSAVE}" != "${DISTRITEXT}" ] && C_SEP="${RED}"
case "${USER}" in
*www*) C_USR="${LIGHTBLUE}";;
*) C_USR="${BROWN}";;
esac
if [ "${UID}" -lt 500 ] || [ "${GID}" -lt 500 ]
then C_USR="${LIGHTCYAN}"
C_HSH="${LIGHTRED}"
fi
[ -n "${C_USR}" ] && H_USR="${OPEN}${C_USR}${CLOSE}"
[ -n "${C_AT}" ] && H_AT="${OPEN}${C_AT}${CLOSE}"
[ -n "${C_HST}" ] && H_HST="${OPEN}${C_HST}${CLOSE}"
[ -n "${C_DIR}" ] && H_DIR="${OPEN}${C_DIR}${CLOSE}"
[ -n "${C_DT}" ] && H_DT="${OPEN}${C_DT}${CLOSE}"
[ -n "${C_HSH}" ] && H_HSH="${OPEN}${C_HSH}${CLOSE}"
[ -n "${C_SEP}" ] && H_SEP="${OPEN}${C_SEP}${CLOSE}"
[ -n "${C_END}" ] && H_END="${OPEN}${C_END}${CLOSE}"
[ -n "${C_EXT}" ] && H_EXT="${OPEN}${C_EXT}${CLOSE}"
[ -n "${C_EXS}" ] && H_EXS="${OPEN}${C_EXS}${CLOSE}"
fi
if ${EX} && ${ZSH}
then PEXT='%(?..:%?)'
PCEXT='%(?.. %?)'
EXT="%(?..${H_EXS}(${H_EXT}%?${H_EXS}%))"
fi
if ${CUT}
then DIR='${D}'
DIRC='${C}'
else DIR="${EDIR}"
DIRC="${DIR}"
fi
PLAIN="${EUSER}@${EHST}${DISTRI} ${DIR}${PEXT}"
PLAINC="${EUSER}@${EHST}${DISTRI}:${DIR}${PCEXT}"
${SCREEN} && case "${TERM}" in
screen*) STATUS="${STARTSSTATUS}${PLAINC}${ENDSSTATUS}";;
esac
${XTERM} && case "${TERM}" in
xterm*|screen*) STATUS="${STATUS}${STARTXSTATUS}${PLAIN}${ENDXSTATUS}";;
esac
if [ -n "${STATUS}" ]
then PS1="${OPEN}${STATUS}${C_USR}${CLOSE}"
else PS1="${H_USR}"
fi
PS1="${PS1}${EUSER}${H_AT}@${H_HST}${EHST}${H_SEP}${SEP}${H_DIR}"
PS1="${PS1}${DIRC}${EXT}${H_HSH}${EPROMPT} ${H_END}"
if ${CUT}
then PDOTS='...'
DOTS="${H_DT}${PDOTS}${H_DIR}"
if ${ZSH}
then D1='D="$(print -P "%~")"'
D2='"${D[0,8]}'
D3='${D[${#D}-15,${#D}]}"'
else D1='D="${PWD#~}"; [ "${D}" = "${PWD}" ] || D="~${D}"'
D2='${D:0:8}'
D3='${D: -16}'
fi
D2='"${D/????????????????????????????*/'"${D2}"; D3="${D3}"'}"'
PS1="\"${PS1}\""
PS1="\$(${D1}; C=${D2}${DOTS}${D3}; D=${D2}${PDOTS}${D3}; echo ${PS1})"
fi
}
if [ -n "${BASH}" ] && \
[ "${BASH_VERSINFO[0]}" -eq 3 ] && [ "${BASH_VERSINFO[1]}" -eq 1 ] && \
[ "${BASH_VERSINFO[2]}" -le 17 ] && [ "${BASH_VERSINFO[3]}" -le 1 ]
then set_prompt -l
# Prompt expansion is buggy in these bash releases - example to test:
#PS1='$(echo "Strange \[\e[0;32m\]Prompt\[\e[0m\] ")'
else set_prompt
fiCode: Select all
setopt prompt_substCode: Select all
bash_source() {
emulate -L sh
setopt kshglob noshglob braceexpand
source "$@"
}Bisher hat mich von anderen Shells grundsätzlich abgeschreckt, dass man sowieso eine bash im Speicher haben sollte, weil sehr vieles sie benutzt - also wieso Platz und (wiederholte) Ladezeit mit einer weiteren Shell verschwenden?Necoro wrote:/me votes for Prompts in zsh ;)
Das erste wäre im zsh stil: [[ -n "$VARIABLE" ]] --- für das zweite - keine Ahnungmv wrote:Immerhin habe ich meine bash-startup-Files mit einigen Änderungen (zsh kennt z.B. kein [[ "$VARIABLE" ]] und kein ${VARIABLE:0:1}) jetzt auch unter der zsh zum Laufen gebracht
Das herauszufinden, war nicht das Problem. Das Problem ist, dass die zsh das [[ $VARIABLE ]] auch im Kompatibilitätsmodus nicht schluckt, sondern Syntaxfehler bringt und das Einlesen/Ausführen der Files abbricht. Daher kann man die wirklich gute /etc/bash_completion sowie einige Files in /etc/bash_completion.d nicht ohne vorheriges Umschreiben einiger Stellen nutzen. Dies wiederum wird natürlich bei upgrades dieser Files Probleme machen. Und wer will schon eine Shell ohne vernünftig vordefinierte Completions nutzen, wenn man dies bei der Bash haben kann?Necoro wrote:Das erste wäre im zsh stil: [[ -n "$VARIABLE" ]] --- für das zweite - keine Ahnung ;)mv wrote:Immerhin habe ich meine bash-startup-Files mit einigen Änderungen (zsh kennt z.B. kein [[ "$VARIABLE" ]] und kein ${VARIABLE:0:1}) jetzt auch unter der zsh zum Laufen gebracht
Ja, ich sollte vielleicht mit Worten erklären, was das PS1-Problem so komplex macht:hab mir dein PS1=$(...) funktions holocaust da oben aber auch net näher zu gemüte geführt. [...] Die zsh hat für alles irgendwo eine Option
Ich kenn die Completions bei der Bash nicht - aber ich weiß, dass ich damals zur zsh gewechselt bin, weil es gerade dort welche gibtmv wrote:Daher kann man die wirklich gute /etc/bash_completion sowie einige Files in /etc/bash_completion.d nicht ohne vorheriges Umschreiben einiger Stellen nutzen. Dies wiederum wird natürlich bei upgrades dieser Files Probleme machen. Und wer will schon eine Shell ohne vernünftig vordefinierte Completions nutzen, wenn man dies bei der Bash haben kann?
Code: Select all
autoload -U compinit
compinitIch sprach von vordefinierten completions. Die zsh-completion hat halt nur ein paar für die Gentoo-Utilities, während app-shells/bash-completion Completions für hunderte von Kommandos hat und z.B. die Optionen und Extensions für spezielle Programme wie mplayer immer wieder aktualisiert werden. Das möchte ich wirklich nicht von Hand für jedes Programm in der zsh nachbauen und ständig aktualisieren. Klar, das erste, was ich in zshrc gemacht hatte, war (in Abwandlung einer FAQ)Necoro wrote:Ich kenn die Completions bei der Bash nicht - aber ich weiß, dass ich damals zur zsh gewechselt bin, weil es gerade dort welche gibtmv wrote:Und wer will schon eine Shell ohne vernünftig vordefinierte Completions nutzen, wenn man dies bei der Bash haben kann?-- tipp: ignorier die bashcompletion und nimm die von zsh -->
emerge -av zsh-completion <--- das bringt dir completion für "equery", "emerge" etc
Code: Select all
bash_source() {
emulate -L sh
local -a BASH_VERSINFO
BASH_VERSINFO=( 3 2 17 1 release )
alias shopt=':'
alias readonly=':'
alias _expand=_bash_expand
alias _complete=_bash_comp
have(){}
alias have=zsh_have
setopt kshglob noshglob braceexpand
source "$@"
}
zsh_have() {
unset have
(( ${+commands[$1]} )) && have=yes
}
alias have=zsh_have
autoload -U compinit bashcompinit
compinit -D
bash_source /etc/bash_completionDas hatte ich mir schon angeschaut, aber leider kann man beim "Kürzen" eben nur einen konstanten String angeben - jedes "%" im "Ersetzungsstring" wird als solches gedruckt statt interpretiert. Dadurch kann man die Filenamen nur an einer Seite kürzen (nicht in der Mitte, wie ich es gerne hätte), und man kann keine Farb-Escape-Sequenzen benutzen, weil sonst die Promptlänge durcheinander käme. Ich habe diese Notlösung jetzt mal im obigen Code eingebaut, aber richtig glücklich bin ich damit nicht.Zu deinem PS1 Problem -> man zshmisc -Sektion "PROMPT EXPANSION" (ist die letzte in der Page)
Sorry -- aber bevor du hier schwachsinn erzählst: Im Paket "zsh-completion" sind wirklich nur die für emerge, equery etc. drin --- die anderen sind standardmäßig vorhanden *kopfschüttel* -- erst ausprobieren - denn Redenmv wrote:Ich sprach von vordefinierten completions. Die zsh-completion hat halt nur ein paar für die Gentoo-Utilities, während app-shells/bash-completion Completions für hunderte von Kommandos hat und z.B. die Optionen und Extensions für spezielle Programme wie mplayer immer wieder aktualisiert werden. Das möchte ich wirklich nicht von Hand für jedes Programm in der zsh nachbauen und ständig aktualisieren. Klar, das erste, was ich in zshrc gemacht hatte, war (in Abwandlung einer FAQ)