OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: Capn_Fish on October 11, 2006, 03:35:10 pm

Title: How Do I Make Mrxvt Show Current Directory?
Post by: Capn_Fish on October 11, 2006, 03:35:10 pm
I would like MRXVT to show the current directory in the prompt.

/mnt/card/#

instead of

#

It would appear from screenshots posted that you can do this, but how?

Thanks
Title: How Do I Make Mrxvt Show Current Directory?
Post by: daniel3000 on October 11, 2006, 05:43:31 pm
I have a solution which shows a shortned path, such as:

root@/usr/bin#

or, if the path gets longer:

root@..ocuments/Sheet_Files#

You can see how to do this in pdaXrom here:
http://www.daniel-hertrich.de/zaurus/zps_pdaxrom/setup.txt (http://www.daniel-hertrich.de/zaurus/zps_pdaxrom/setup.txt)

In short:

/etc/profile needs these two additional lines:

Code: [Select]
export PROMPT_COMMAND="pwdtrunc"
export PS1='\u@$(cat /tmp/pwdtrunc.$EUID)> '

and you need a script called "pwdtrunc" somewhere in your PATH containing the following:

Code: [Select]
#!/bin/bash
# pwdtrunc - truncates $PWD, writes to /tmp/pwdtrunc.$EUID
# Mainly from Bash-Prompt-HOWTO, enhanced by Tilman Brock

# How many characters of the $PWD should be kept
pwdmaxlen=20

# Indicator that there has been directory truncation:
trunc_symbol=".."

###
if [ ${#PWD} -gt $pwdmaxlen ]
then
  pwdoffset=$(( ${#PWD} - $pwdmaxlen ))
  newPWD="${trunc_symbol}${PWD:$pwdoffset:$pwdmaxlen}"
else
  newPWD=${PWD}
fi
nPWD="`echo $newPWD | sed -e s=$HOME=~=` "
echo $nPWD > /tmp/pwdtrunc.$EUID

If you just want to see the entire current directory in the prompt, forget about the script and PROMPT_COMMAND variable and just use the variable PS1 in /etc/profile:

Code: [Select]
export PS1='$(pwd)$ '

have fun!
daniel
Title: How Do I Make Mrxvt Show Current Directory?
Post by: Capn_Fish on October 11, 2006, 06:16:51 pm
Using XFCE and ROX, it starts fine from the menu, but my desktop icon doesn't start it with the prompt. How can I fix that?

Thanks!
Title: How Do I Make Mrxvt Show Current Directory?
Post by: daniel3000 on October 12, 2006, 03:31:04 am
Quote
Using XFCE and ROX, it starts fine from the menu, but my desktop icon doesn't start it with the prompt. How can I fix that?

Thanks!
[div align=\"right\"][a href=\"index.php?act=findpost&pid=143773\"][{POST_SNAPBACK}][/a][/div]

I have no idea why this could be the case.
Maybe the /etc/profile file is not evaluated for the desktop icon's execution?
Does the desktop icon call another command than the menu entry?

daniel
Title: How Do I Make Mrxvt Show Current Directory?
Post by: Capn_Fish on October 12, 2006, 07:49:14 am
I think it must execute the app in a different way somehow. I have to put the full path to the executable in the shortcut, then any options I want under it. I manged to get it to execute mostly the same as from the menu by putting the same options as the .desktop file as in the shortcut, but it still gave (at least before doing like you said, maybe now, I haven't checked) me a "bash..#" prompt, while the menu icon gave me none at all. Does this help?

Thanks for your help.
Title: How Do I Make Mrxvt Show Current Directory?
Post by: karlto on October 12, 2006, 02:41:07 pm
Quote
Maybe the /etc/profile file is not evaluated for the desktop icon's execution?
Probably - most terminal apps have an '-l' switch or similar to run with full login shell. You probably want to use it in this mode.
Title: How Do I Make Mrxvt Show Current Directory?
Post by: Capn_Fish on October 12, 2006, 03:13:07 pm
Thanks! Once I added the export PS1='$(pwd)$ ' line to /etc/profile and added -ls as an option to mrxvt it works! I had to add it to both the .desktop file and the shrtcut, but it only took 5 seconds, give or take a few.
Title: How Do I Make Mrxvt Show Current Directory?
Post by: anunakin on October 13, 2006, 07:51:00 am
I using it:
edit /etc/profile .... and:
replace PS1='# ' for:
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '