Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
10-17-2004, 08:29 PM
#31
Member
Registered: Sep 2003
Distribution: Gentoo
Posts: 135
Rep:
Quite simple...
I'm using zsh, and I have my mary@linux on the left and my present directory on the right.
Last edited by mary; 10-17-2004 at 08:30 PM .
10-18-2004, 07:53 PM
#32
Member
Registered: Aug 2004
Distribution: debian, SuSE
Posts: 365
Rep:
My prompt?
3 lines long
username on host.domain:/home/username
cmd->
Done as
PS1="
`whoami` on `hostname:\$PWD
cmd-> "
root's is slightly modified as
root on host.domain:/root
Simon Says->
10-18-2004, 08:02 PM
#33
Senior Member
Registered: Dec 2001
Location: 35.7480° N, 95.3690° W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070
Rep:
james@poseidon ~ $
james@poseidon is in green
path and $ is in blue
For root
root@poseidon ~ #
root@poseidon in red
path and # is in blue
Code:
# Define some colors first:
red='\033[0;31m'
RED='\033[1;31m'
green='\033[0;32m'
GREEN='\033[1;32m'
yellow='\033[0;33m'
YELLOW='\033[1;33m'
blue='\033[0;34m'
BLUE='\033[;1;34m'
purple='\033[0;35m'
PURPLE='\033[1;35m'
cyan='\033[0;36m'
CYAN='\033[1;36m'
white='\033[0;37m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
function MyPrompt {
case $TERM in
*term* | rxvt )
PS1="$GREEN\u@\h $BLUE\w \$$NC \[\033]0;\u@\h \w\007\]" ;;
*)
PS1="\u@\h: \w \$ ";;
esac
}
fi
MyPrompt
10-18-2004, 11:45 PM
#34
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908
bigrigdriver Mon Oct 18] $ /path/to/working/directory. Red if I su to root; blue otherwise.
I have this in /etc/bashrc;
# bash-specific settings
ROOT_UID=0
if [ "$UID" -eq "$ROOT_UID" ]
then
PS1="\[\033[31;1m\]\u \d] \\$\w\n \[\033[0m\]"
else
PS1="\[\033[34;1m\]\u \d] \\$\w\n \[\033[0m\]"
fi
11-01-2004, 06:28 AM
#35
Member
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729
Rep:
How do I get my prompt to show instead of ${PWD}, just the last 3 levels of the path ?
11-01-2004, 08:53 AM
#36
LQ Newbie
Registered: Nov 2004
Posts: 5
Rep:
7h15 15 ]V[1]\[3
:
: fugu@oni-tng
/etc : :
Code:
PS1="\[\033[1;30m\]:\[\033[1;33m\]: \[\033[1;30m\]\u@\h \[\033[1;33m\]\w \[\033[1;33m\]:\[\033[1;30m\]:
Last edited by fili; 11-01-2004 at 08:54 AM .
11-01-2004, 03:15 PM
#37
Member
Registered: Oct 2004
Location: US
Distribution: Fedora Core 1
Posts: 43
Rep:
for regular user:
[Mon Nov 1][user@percentageness]
[~/music]$
for root:
[Mon Nov 1][root@percentageness]
[/etc][YOU ARE ROOT]#
for regular users:
PS1="[\d][\u@percentageness]\n[\w]\$ "
for root
PS1="[\d][\u@percentageness]\n[\w][YOU ARE ROOT]\# "
11-02-2004, 01:30 PM
#38
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Original Poster
Rep:
Quote:
Originally posted by davholla
How do I get my prompt to show instead of ${PWD}, just the last 3 levels of the path ?
Try this:
Code:
PS1="Last 3: \`pwd|awk --field-separator='/' {'print \$(NF-2)\"/\"\$(NF-1)\"/\"\$(NF)'}\` # "
11-02-2004, 02:46 PM
#39
Member
Registered: Aug 2004
Location: Atlanta
Distribution: Slackware 10
Posts: 85
Rep:
My home prompt is pretty complex:
Code:
\[\033[0;34m\][\[\033[0;35m\]\u\[\033[0;34m\]@\[\033[0;35m\]\h\[\033[0;34m\]]\[\033[1;37m\]:\[\033[0;31m\]\@\[\033[1;37m\]:\[\033[0;31m\]\d\n\[\033[0;34m\][\[\033[0;31m\]\w\[\033[0;34m\]]\[\033[1;37m\]::
Which looks something like this:
[ user @ host ] : current time : current date
[ pwd ] ::
While my work prompt is very simple:
11-04-2004, 05:43 AM
#40
Member
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729
Rep:
Quote:
Originally posted by david_ross
Try this:
Code:
PS1="Last 3: \`pwd|awk --field-separator='/' {'print \$(NF-2)\"/\"\$(NF-1)\"/\"\$(NF)'}\` # "
Now it looks like :-
3: `pwd|awk --field-separator='/' {'print $(NF-2)/$(NF-1)/$(NF)'}` #
By the way this is not Linux it is HP tru 64
01-01-2005, 11:23 PM
#41
LQ Newbie
Registered: Jan 2005
Posts: 5
Rep:
echo $PS1
\033[35m\]\nDirectory:\[\033[32m\]\w\n\[\033[1;31m\]\u@\h: \[\033[1;34m\]$(/usr/bin/tty | /bin/sed -e 's:/dev/::'): \[\033[1;36m\]$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files \[\033[1;33m\]$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[0m\] -> \[\033[0m\]
---
Ends Up Lookin Like This
Directory: ~
root@localhost: pts/4: 71 files 1.1Gb ->
Last edited by linuxgodrh; 01-01-2005 at 11:30 PM .
03-26-2011, 11:56 AM
#42
Senior Member
Registered: Dec 2008
Posts: 4,731
After 6 years
Code:
16:52:49 Sat Mar 26 anisha ~ fortune
"I haven't lost my mind; I know exactly where I left it."
PS1="\e[0;36m\t \d \u \w \e[m "
03-27-2011, 01:03 AM
#43
Member
Registered: Jan 2011
Location: IN
Distribution: Arch x64 multilib
Posts: 79
Rep:
for me:
[
bread @staircase:~]$
and for root:
[
root @staircase:~]#
.zshrc
Code:
PS1="[$PR_WHITE%n$PR_NO_COLOR@$PR_NO_COLOR%m%u$PR_NO_COLOR:$PR_NO_COLOR%2c$PR_NO_COLOR]%(!.#.$) "
\o/
03-27-2011, 01:28 AM
#44
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Using zsh:
After a successful command:
tobi@dragon ~
:) %
After an unsuccessful command:
tobi@dragon ~
:( %
Code:
PROMPT=$'%n@%m %0(3c,%c,%~) %0(?,%{\e[0;32m%}:%),%{\e[0;31m%}:(%s)%b %# '
1 members found this post helpful.
03-27-2011, 01:37 AM
#45
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep:
Mine is simple: nick@vega:~$
All times are GMT -5. The time now is 07:10 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News