Het komt vaak voor dat je op de tekst console een andere prompt hebt dan in (bv) een xterm onder X.
Op de console wordt bijvoorbeeld de huidige directorie in de prompt weergegeven:
bilbo@bilbo:~$ cd /usr/src/linux
bilbo@bilbo:/usr/src/linux$
|
en in een xterm zie je dan dit
bash-2.05a$ cd /usr/src/linux/
bash-2.05a$ pwd
/usr/src/linux
bash-2.05a$
|
Beetje irri, toch?
Zoals zo vaak is het antwoord te vinden in de manpages. In dit geval in de manpage van bash...... maar dat is een hond van een document (5142 regels!). Kom daar als newbie maar een uit, als je al weet dat je manpage van bash nodig hebt.
Daarom hier de (beperkte) info van wat ik er van weet:
Probleem is dat bash op 2 manieren gestart kan worden.
Uit de manpage
INVOCATION
A login shell is one whose first character of argument
zero is a -, or one started with the --login option.
An interactive shell is one started without non-option
arguments and without the -c option whose standard input
and output are both connected to terminals (as determined
by isatty(3)), or one started with the -i option. PS1 is
set and $- includes i if bash is interactive, allowing a
shell script or a startup file to test this state.
|
Het komt er op neer dat bash:
Het probleem is nu dat bash voor elke van deze 2 methodes verschillende opstart bestanden gebruikt.
Uit de manpage
When bash is invoked as an interactive login shell, or as
a non-interactive shell with the --login option, it first
reads and executes commands from the file /etc/profile, if
that file exists. After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile, in that
order, and reads and executes commands from the first one
that exists and is readable. The --noprofile option may
be used when the shell is started to inhibit this behav-
ior.
|
en ff verder op
When an interactive shell that is not a login shell is
started, bash reads and executes commands from ~/.bashrc,
if that file exists. This may be inhibited by using the
--norc option. The --rcfile file option will force bash
to read and execute commands from file instead of
~/.bashrc.
|
Het komt er op neer dat:
So what zal je zeggen!
Nou juist in /etc/profile en ~/.bashrc wordt je prompt aangemaakt. Zoek in dat bestand maar eens naar de tekst PS1. Hier heb je de mijne:
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
PS1='$ '
else
PS1='\u@\h:\w\$ '
fi
PS2='< '
export PATH DISPLAY LESS TERM PS1 PS2
|
Dit betekent dat indien je geen ~/.bashrc hebt, je dus ook geen netjes ingestelde prompt krijgt, maar de default prompt van bash. En aan die prompt heb je dus niet veel.
Maar Linux zou Linux niet zijn als het kennen van het probleem 3/4 van de oplossing is. Je hebt verschillende opties.
Bijgaand voorbeelden uit de manpages van xterm en rxvt:
xterm:
-ls This option indicates that the shell that is started in
the xterm window will be a login shell (i.e., the first
character of argv[0] will be a dash, indicating to the
shell that it should read the user's .login or .profile).
|
rxvt:
-ls|+ls
Start as a login-shell/sub-shell; resource loginShell.
|
Voor zover ik weet kan aan console (van kde) ook de optie "-ls" meegegeven worden. Console heeft geen manpage :(.
| E-Mail: bilbo@nedlinux.nl | Home: http://www.bilbos-stekkie.com | Laatste wijziging: 20-03-06 13:00:09 CET |