Help - Search - Members - Calendar
Full Version: How Do I Make Mrxvt Show Current Directory?
OESF Forums > Distros, Development, and Model Specific Forums > Distro Support and Discussion > pdaXrom
Capn_Fish
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
daniel3000
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
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
#!/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
export PS1='$(pwd)$ '



have fun!
daniel
Capn_Fish
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!
daniel3000
QUOTE(Capn_Fish @ Oct 12 2006, 12:16 AM)
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!
*


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
Capn_Fish
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.
karlto
QUOTE(daniel3000 @ Oct 12 2006, 08:31 PM)
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.
Capn_Fish
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.
anunakin
I using it:
edit /etc/profile .... and:
replace PS1='# ' for:
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.