Date: Thu, 2 Jul 2020 20:09:15 +0200 From: Polytropon <freebsd@edvax.de> To: Brandon helsley <brandon.helsley@hotmail.com> Cc: Per Hedeland <per@hedeland.org>, freebsd-questions <freebsd-questions@freebsd.org> Subject: Re: Shell Message-ID: <20200702200915.0ef85318.freebsd@edvax.de> In-Reply-To: <CY4PR19MB0104D3CC0D3BF13B93AB8A1BF96D0@CY4PR19MB0104.namprd19.prod.outlook.com> References: <20200630143913.e27eb3e3.freebsd@edvax.de> <CY4PR19MB010400AC4940C67421BFADE8F96E0@CY4PR19MB0104.namprd19.prod.outlook.com> <DB8PR06MB6442289C119C69BDF4303E72F66F0@DB8PR06MB6442.eurprd06.prod.outlook.com> <20200630104317.812dce86b2dc5ea5a42a1ee1@sohara.org> <a590654c-ffa2-3171-ce44-ae3f33214b14@hedeland.org> <20200630143913.e27eb3e3.freebsd@edvax.de> <CY4PR19MB0104D3CC0D3BF13B93AB8A1BF96D0@CY4PR19MB0104.namprd19.prod.outlook.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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@machine17# instead > of root@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 echo $SHELL 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 the command chsh to make the change. Check the content of the shells database with cat /etc/shells 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 if neccessary. It doesn't help if you edit /bin/csh's configuration file, but you're using /bin/sh. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200702200915.0ef85318.freebsd>