Author Topic: How Do I Make Mrxvt Show Current Directory?  (Read 3564 times)

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« 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
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« Reply #1 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

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
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« Reply #2 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!
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« Reply #3 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
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« Reply #4 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.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

karlto

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« Reply #5 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.
SL6000-L, RC12

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
How Do I Make Mrxvt Show Current Directory?
« Reply #6 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.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

anunakin

  • Sr. Member
  • ****
  • Posts: 340
    • View Profile
    • http://vivaphp.net
How Do I Make Mrxvt Show Current Directory?
« Reply #7 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\] '
[img]http://www.vivaphp.net/imagens/rev2.jpg\" border=\"0\" class=\"linked-sig-image\" /]
Anunakin (Marcus Fazzi)

Nokia N900 32GB + microSD 2GB
Nokia N810 w/ microSD 8GB
Nokia 5310 XpressMusic w/ microSD 1GB
HP48GX->Psion Sienna->Palm m130->Tungsten T->Zaurus SL-5500->C3000->C3100 ALL SOLD

My FEED(On Line AGAIN!!!)