Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Missing directory indication in prompt- bash problem?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
jthompson
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 159
Location: Pompano Beach, FL

PostPosted: Fri Jun 17, 2005 1:33 pm    Post subject: Missing directory indication in prompt- bash problem? Reply with quote

I just recently updated baselayout-config and bash. I use dispatch-conf, so I have all of the old files in /etc/config-archive. I seem to not have broken too much, but I am now missing the directory indicator at the terminal prompt.

Code:
bas-backup ~ #


Where should I look?
Is this a bash problem?

When I updated baselayout-config I had to update some 37 config files, I tried to do most of them interactively and keep the necessary changes.

The machine still works, I was able to reboot it and everything seems ok, I think. I would just like to get my prompt back to normal.

Perhaps updating the package baselayout-config is a bad idea?
_________________
I can't remember from noon to lunchtime!
Back to top
View user's profile Send private message
ansient
Guru
Guru


Joined: 22 Jan 2005
Posts: 445
Location: Argentina

PostPosted: Fri Jun 17, 2005 1:40 pm    Post subject: Reply with quote

~ is the directory!

~ is short for $HOME.

try:
Code:
cd /
cd ~
cd ..
cd -
Back to top
View user's profile Send private message
jthompson
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 159
Location: Pompano Beach, FL

PostPosted: Fri Jun 17, 2005 1:45 pm    Post subject: Reply with quote

Code:
bas-backup / # cd /
bas-backup / # cd ~
bas-backup ~ # cd ..
bas-backup / # cd -
/root
bas-backup ~ # pwd
/root
bas-backup ~ # cd ..
bas-backup / # pwd
/
bas-backup / #


Ok I did the following and I'm confused... So its supposed to show ~?
_________________
I can't remember from noon to lunchtime!
Back to top
View user's profile Send private message
ansient
Guru
Guru


Joined: 22 Jan 2005
Posts: 445
Location: Argentina

PostPosted: Fri Jun 17, 2005 1:48 pm    Post subject: Reply with quote

jthompson wrote:
So its supposed to show ~?

Yes!

also try:
Code:
cd ~someotherusername       # replace someotherusername that of some other user on your system
cd ~root

"cd" is short for "cd ~" which is short for "cd ~yourusername" which is short for "cd /path/to/your/home/directory"
Back to top
View user's profile Send private message
jthompson
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 159
Location: Pompano Beach, FL

PostPosted: Fri Jun 17, 2005 1:52 pm    Post subject: Reply with quote

Silly question, how come in the earlier version of bash, it showed /root or /username?
Now it doesn't?
_________________
I can't remember from noon to lunchtime!
Back to top
View user's profile Send private message
ansient
Guru
Guru


Joined: 22 Jan 2005
Posts: 445
Location: Argentina

PostPosted: Fri Jun 17, 2005 2:03 pm    Post subject: Reply with quote

I think that varies on wether your $PS1 contains \w or \W.

Global PS1 now gets set in /etc/bash/bashrc (called from /etc/profile), but you are free to overide this in each user's ~/.bashrc

And you'll have to have ~/.bash_profile source ~/.bashrc for it to work all the time.

Here's some code from my personal ~/.bashrc, which you may or may not be interested in:
Code:
# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.
use_color=false
safe_term=${TERM//[^[:alnum:]]/.}   # sanitize TERM

if [[ -f /etc/DIR_COLORS ]]; then
   grep -q "^TERM ${safe_term}" /etc/DIR_COLORS && use_color=true
elif dircolors --print-database | grep -q "^TERM ${safe_term}"; then
   use_color=true
fi

function friendly_pwd {
   if [[ "${PWD}" == "${HOME}" ]]; then
      echo "~${USER}"
   else
      echo ${PWD}
   fi
   return
}

if ${use_color}; then
   if [[ $EUID == 0 ]]; then # root user = green all uppercase hostname
      DHOST="\[\033[01;31m\]$(echo ${HOSTNAME} | tr '[:lower:]' '[:upper:]')"
      PS1="${DHOST} \[\033[01;34m\]\$(friendly_pwd) # \[\033[00m\]"
#      PS1='\[\033[01;31m\]${DHOST} \[\033[01;34m\]\W \$ \[\033[00m\]'
#      PS1='\[\033[01;31m\]`echo \h | tr [:lower:] [:upper:]`:\[\033[01;34m\]\W \$ \[\033[00m\]'
   else if [[ $EUID == 1000 ]]; then # main user = green regular case hostname
         DHOST="\[\033[01;32m\]${HOSTNAME}"
      else # some other user = yellow regular case hostname
         DHOST="\[\033[01;33m\]${HOSTNAME}"
      fi
      PS1="${DHOST} \[\033[01;34m\]\$(friendly_pwd) \$ \[\033[00m\]"
   fi
   
else # we don't have colors
   if [[ $EUID == 0 ]]; then
      PS1='root@${HOSTNAME} $PWD # '
   else
      PS1='${USER}@${HOSTNAME} ${PWD##*/} \$ '
   fi
fi

It's not perfect... friendly_pwd could use some enhancements, for instance I'd like it to show "~$USERNAME" whenever the current diretory is the home directory of $USERNAME.


Last edited by ansient on Fri Jun 17, 2005 2:11 pm; edited 2 times in total
Back to top
View user's profile Send private message
bonistatusta
n00b
n00b


Joined: 16 Jun 2005
Posts: 5
Location: dou wo der glub spüilt

PostPosted: Fri Jun 17, 2005 2:05 pm    Post subject: Reply with quote

Extra informative Bash prompt
Bash prompt
Cool prompt
HOWTO: Customize bash shell prompt
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum