Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My Turnkeylinux machine uses the following PS1 environment variable for bash prompt:

PS1="${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h \[\033[01;34m\]$(promptpath)\[\033[00m\]\$"

I plugged the above into what is essentially a stock "Debian GNU/Linux 6.0 \n \l" and it complained about "promptpath" being unavailable.

I tried "which promptpath", and its result was NULL (it found nothing). Since promptpath doesn't seem to be a program, what is it?

What must I do to make promptpath available on the stock Debian machine so that the prompt works without any changes?

share|improve this question
What does which promptpath return on the Turnkey machine? – nickgrim Oct 23 '12 at 15:32
Run type promptpath on the Turnkey machine. This will show what it is. Likely, it's a TurnKey Linux-ism, where it's some function defined in the system-wide bash_profile. If that's the case, you can try to replicate the function, or just remove it from your Debian $PS1. – cjc Oct 23 '12 at 15:36
type -- learned a new command. Thanks :3 – starlocke Oct 23 '12 at 15:38
up vote 1 down vote accepted

I looked into my ~/.bashrc and promptpath is some kind of user-defined function.

# Set prompt path to max 2 levels for best compromise of readability and usefulness
promptpath () {
    realpwd=$(realpath $PWD)
    realhome=$(realpath $HOME)

    # if we are in the home directory
    if echo $realpwd | grep -q "^$realhome"; then
        path=$(echo $realpwd | sed "s|^$realhome|\~|")
        if [ $path = "~" ] || [ $(dirname $path) = "~" ]; then
            echo $path
            echo $(basename $(dirname $path))/$(basename $path)

    path_dir=$(dirname $PWD)
    # if our parent dir is a top-level directory, don't mangle it
    if [ $(dirname $path_dir) = "/" ]; then
        echo $PWD
        path_parent=$(basename $path_dir)
        path_base=$(basename $PWD)

        echo $path_parent/$path_base

I simply copied the TurnkeyLinux ~/.bashrc to my Debian machine.

share|improve this answer
if you answered your own question please select it as accepted so this issue can be closed :) – Jan Wikholm Jan 4 '13 at 7:53
I forgot to do so, because the site required something like 24 hours before I would be allowed to just that XD – starlocke Jan 5 '13 at 2:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.