You are not logged in.

#1 2009-02-01 19:47:25

saf
Member
Registered: 2009-02-01
Posts: 39

show local path in terminal

hello,

in my ttys it work but in my gnome-terminal it dont show me the folder I am inside.
always only bash-3.2 or sh-3.2

but i want for example [me@host /usr/bin]$ like i know it from other distributions

some one any idea?

Thanks

Last edited by saf (2009-02-01 19:48:01)

Offline

#2 2009-02-01 19:56:58

Lexion
Member
Registered: 2008-03-23
Posts: 510

Re: show local path in terminal

You are probably logged in as root. echo $USER will display what user you are logged in as.  How do you start X11?


urxvtc / wmii / zsh / configs / onebluecat.net
Arch will not hold your hand

Offline

#3 2009-02-01 19:57:31

Vladman
Member
Registered: 2009-01-28
Posts: 118

Re: show local path in terminal

run this in terminal
source /etc/profile

Offline

#4 2009-02-01 20:08:36

xaiviax
Member
From: Michigan
Registered: 2008-11-04
Posts: 282

Re: show local path in terminal

Offline

#5 2009-02-01 21:24:22

saf
Member
Registered: 2009-02-01
Posts: 39

Re: show local path in terminal

hi
@lexion i start X11 over gdm as daemon in rc.conf

Hi Vladman,
thats almost great,
it shows the folder where i am but not the full path. is this possible?
Is it possible to let terminator or gnome-terminal run this command automatically when i start it?

hi xalviax, thanks for this links its interesting

Offline

#6 2009-02-01 22:12:59

biagio
Member
From: Florence - Italy
Registered: 2008-02-29
Posts: 49

Re: show local path in terminal

saf wrote:

i want for example [me@host /usr/bin]$ like i know it from other distributions

paste this in ~/.bashrc

 PS1='\u@\h [\w]\$ '

Offline

#7 2009-02-01 22:20:02

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: show local path in terminal

This is my method, in $HOME/.bashrc:

TTY=$(basename $(tty))
HOSTNAME=$(hostname)
export PS1="\n$HOSTNAME - $LOGNAME ($TTY) [$SHLVL] - \$PWD\n> "

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#8 2009-02-02 02:42:17

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,563

Re: show local path in terminal

The PS1 environment variable controls that, as you've probably seen from the others. Googling can provide more info on customizing it, as well as man pages.

Also, the whereami command should say - well, it's obvious.

Last edited by Ranguvar (2009-02-02 16:00:56)

Offline

#9 2009-02-02 13:31:29

saf
Member
Registered: 2009-02-01
Posts: 39

Re: show local path in terminal

hi guys
cool I didnt know u can modify it so much, i choosed this, based on the code from Mektub, without \n like biagio did

export PS1="[\u@\h \$PWD]$ "

and in /root/ i put same .bashrc exept with a # instead of the $ at the end

thanks

Last edited by saf (2009-02-02 13:42:19)

Offline

#10 2009-02-02 13:58:19

biagio
Member
From: Florence - Italy
Registered: 2008-02-29
Posts: 49

Re: show local path in terminal

saf wrote:
export PS1="[\u@\h \$PWD][b]$[/b] "

and in /root/ i put same .bashrc exept with a # instead of the $ at the end

$ and \$ are not the same thing.

if you are root, \$ returns "#" in the prompt
if you are <user>, \$ returns "$"

Last edited by biagio (2009-02-02 14:10:26)

Offline

#11 2009-02-02 14:06:12

jordz
Member
Registered: 2006-02-01
Posts: 250

Re: show local path in terminal

You should make a symbolic link  .bash_profile -> .bashrc smile

Do that for example for the root user, normally tty will be ok but when you do su in gnome,
you will get bash-3.2 because .bashrc doesn't get sourced.

Last edited by jordz (2009-02-02 14:07:54)

Offline

#12 2009-02-02 14:15:25

saf
Member
Registered: 2009-02-01
Posts: 39

Re: show local path in terminal

ah okay it makes the change between # and $ automatically

i made now 

PS1='\n[\u@\h \w]\$ '

@symlink
u mean ln -s .bashrc .bash_profile in home and /root/

Last edited by saf (2009-02-02 14:18:14)

Offline

#13 2009-02-02 14:32:52

jordz
Member
Registered: 2006-02-01
Posts: 250

Re: show local path in terminal

saf wrote:

@symlink
u mean ln -s .bashrc .bash_profile in home and /root/

Yes for every user you want to fix this problem.
Normally .bash_profile sources .bash_rc, but it doesn't work when you su in X to a different user.
If you want the same bash settings in tty and X ,that's the easiest way to fix this.

Offline

#14 2009-02-02 16:15:50

saf
Member
Registered: 2009-02-01
Posts: 39

Re: show local path in terminal

okay i did
ty

Offline

Board footer

Powered by FluxBB