freebsd at edvax.de
Thu Jul 2 18:09:23 UTC 2020
On Thu, 2 Jul 2020 10:53:19 -0600, Brandon helsley wrote:
> Thank you all for the help. I think I was not specific enough
> with my problem. I now know how to change the prompt to what
> I want but still have to issue the command "pwd" to see what
> directory I'm in. For example, when I cd to the /usr/home/
> directory my prompt is still only root at machine17# instead
> of root at machine17#~/usr/home/
First of all, you have to determine _which shell_ you are using
at the moment - and if it is the shell you _want_ to be using.
Use the command
to find out. Depending on what shell it is, the file to change,
and the syntax of the change is different.
If your shell is /bin/sh, but you want to use the C shell, use
to make the change. Check the content of the shells database
to find out which entries are valid for the shell field.
For the C shell, entry "/bin/csh", the configuration file for
the user is ~/.cshrc (/home/<name>/.cshrc and /root/.cshrc),
and global settings go to /etc/csh.cshrc.
Add the following lines to /etc/csh.cshrc:
set prompt = "%N@%m:%~%# "
set promptchars = "%#"
Now all users will have a standard UNIX prompt, except (!) they
override it in their own configuration file (mentioned above).
This mechanism will also add the correct "power indicator",
# or %, automatically.
If you insist on using /bin/sh, then you have to edit the
user's ~/.profile file; for a user:
export PS1="`whoami`@`hostname | sed 's/\..*//'`:`pwd`\$ "
And for root:
export PS1="`whoami`@`hostname | sed 's/\..*//'`:`pwd`# "
This works similar to how the C shell presents the prompt,
except that $HOME will not be abbreviated with ~. Also the
selection of # and $ is done manually here.
If you have installed bash, and you want to use that shell,
use ~/.bashrc to set the prompt:
export PS1="\u@\h:\w\$ "
If you want a more Linux-like prompt, use this:
export PS1="[\u@\h] \w \$ "
If you simply add those entries at the end of the files, any
previously existing definition will be overridden, which is
what is intended here.
So allow me to summarize:
1. Determine which shell you are currently using.
2. If it is the shell you want to use, goto 4.
3. Change the shell to the one you want to use.
4. Check the shell's configuration file and make additions
It doesn't help if you edit /bin/csh's configuration file,
but you're using /bin/sh. ;-)
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions