2

Need help to change the command prompt. I want short name. Look below :

kirti@kirti-Aspire-5733Z:~$ cd workspace
kirti@kirti-Aspire-5733Z:~/workspace$ cd Ruby
kirti@kirti-Aspire-5733Z:~/workspace/Ruby$

I am looking for my initial command prompt, when I will open it using 'Ctrl+Alt+t' as

 $(arup):
 $(arup): cd workspace
 $(workspace): cd Ruby
 $(Ruby) :

In my ~/.bashrc file did put as below :

if [ "$color_prompt" = yes ]; then
PROMPT_DIRTRIM=1
PS1='\w\ $ '
else
PS1='\w\ $ '

By replacing

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    # PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS1='arup :\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

But I didn't find any change in my shell:

enter image description here May I have some help to configure the above settings ?

  • are you updating the bashrc source with " source ~/.bashrc "? (no quotes) – MuffinStateWide Jan 1 '14 at 7:34
  • @MuffinStateWide I open ~/.bashrc using Gedit, then put the content and saved it. That's what I did and tried. But no result. – Arup Rakshit Jan 1 '14 at 7:42
  • @MuffinStateWide It is not permanent, every time I need to source it. kirti@kirti-Aspire-5733Z:~$ source ~/.bashrc ~\ $ cd workspace ~/workspace\ $ cd Ruby ~/workspace/Ruby\ $ But this is not what I was looking for. – Arup Rakshit Jan 1 '14 at 7:46
2

I took help from How to: Change / Setup bash custom prompt (PS1)

I did first sudo gedit /etc/bashrc. Then did below change :

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='(arup~>\W)$'

Now my prompt is coming close to my expectation -

enter image description here

0

In ~/.bashrc, search for section:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

Remove the @\h, and replace the \w with an uppercase \W, so that it becomes:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
fi

check this for more info

  • I tried, but no luck! – Arup Rakshit Dec 31 '13 at 6:27
0

enter image description here

you can create an alias for cd ~/workspace/Ruby as chg_dir

  • I want it to be happened dynamically... See my post description.. – Arup Rakshit Dec 31 '13 at 6:17
  • sorry I got it wrong, I edited my answer. Is this something you are looking for ? – Rakesh Godhala Dec 31 '13 at 6:27
  • No.. I am looking for $(arup): to come when I open the terminal,then each time I will change the CWD, it should come as $(CWD_name).. – Arup Rakshit Dec 31 '13 at 6:31
  • I would advice you NOT to change root prompt name. It always shows as username@hostname so that when someone connect to other machine with ssh it changes to remote-username@remote-hostname. However, you can force terminal to always show present-working-directory(PWD/CWD) instead of full directory path like in this image. – Khurshid Alam Jan 3 '14 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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