Sep 23 2012

Howto: Working Directory in Synology DS211j Shell Prompt

Synology DS211j has ash as the default shell. It has some basic features, such as tab-complete. However one of the features in other shells (such as bash) is missing: dynamic display of working directory in shell prompt. The default prompt is noninformative “DiskStation>“. Fortunately it is easy to change it to display current working directory. Here’s how:

  1. In your home directory: vi .profile
  2. vi editor is not very intuitive so you first need to enter “edit mode” by pressing “i” (insert).
  3. Comment out the line: PS1=”`hostname`> “ by adding a dash (#) in the beginning of the line
  4. Then copy-paste the following lines below it:
    PS1="`whoami`@`hostname | sed 's/\..*//'`:\w"
    case `id -u` in
    0) PS1="${PS1}# ";;
    *) PS1="${PS1}$ ";;
    esac
  5. Exit edit mode by pressing Esc.
  6. Save and exit the editor by typing :wq and hitting Enter.
  7. Log out and log in again and there you have it!

Enjoy 🙂

One Response to “Howto: Working Directory in Synology DS211j Shell Prompt”

Leave a Reply