Saturday, May 11, 2024
318
rated 0 times [  318] [ 0]  / answers: 1 / hits: 261050  / 2 Years ago, sat, february 19, 2022, 4:11:05

Currently it is:



michael@Castle2012-Ubuntu-laptop01:~/Dropnot/webs/rails_v3/linker/spec/controllers$


Outside of renaming my machine and directory structure...



How could I make it be something more like:



michael:controllers$

More From » command-line

 Answers
2

To change it for the current terminal instance only


Just enter PS1='u:W$ ' and press enter.




To change it "permanently"


In your ~/.bashrc, find the following 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

Save, exit, close terminal and start another to see the result.




Tons more options!



  • See here for a more extensive howto, with many more options

  • See this answer for using up a tiny Python script to set the prompt so that the shortening only occurs when you are deep in a directory structure.


[#37919] Sunday, February 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rvousnove

Total Points: 456
Total Questions: 130
Total Answers: 98

Location: El Salvador
Member since Sun, Sep 12, 2021
3 Years ago
;