set bash prompt

Posted By Sagar Patil

I need to remind myself on what machine & directory I am working on constantly. The easiest way to do so would be setting PS1 prompt under bash shell.

For example,
Name of Server : Server1
Pwd : /opt/IBM/WebSphere/AppServer/profiles/Profile01/Node
TAG : [Dev] Uatf]

export TAG=Dev/Uatf/Test

export PS1=‘${HOSTNAME:0:10}-$(echo $PWD|awk “{print substr(\\$1,length(\\$1)-24,25)}”)-${TAG:0:4}# ‘

returned  Server1-/logs/uatf_server_member1-Dev#

To Display HOSTNAME In caps do

export PS1=’$(echo ${HOSTNAME:0:10}|tr “[a-z]” “[A-Z]“)-$(echo $PWD|awk “{print substr(\\$1,length(\\$1)-24,25)}”)-${TAG:0:4}# ‘

returned SERVER1-/logs/uatf_server_member1-Dev#

Leave a Reply

You must be logged in to post a comment.

Top of Page

Top menu