LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 10-17-2004, 08:29 PM   #31
mary
Member
 
Registered: Sep 2003
Distribution: Gentoo
Posts: 135

Rep: Reputation: 15

Quite simple...

Code:
mary@linux %                                              ~
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.
 
Old 10-18-2004, 07:53 PM   #32
amfoster
Member
 
Registered: Aug 2004
Distribution: debian, SuSE
Posts: 365

Rep: Reputation: 36
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->
 
Old 10-18-2004, 08:02 PM   #33
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
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
 
Old 10-18-2004, 11:45 PM   #34
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
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
 
Old 11-01-2004, 06:28 AM   #35
davholla
Member
 
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729

Rep: Reputation: 32
How do I get my prompt to show instead of ${PWD}, just the last 3 levels of the path ?
 
Old 11-01-2004, 08:53 AM   #36
fili
LQ Newbie
 
Registered: Nov 2004
Posts: 5

Rep: Reputation: 0
Talking

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.
 
Old 11-01-2004, 03:15 PM   #37
XsuX
Member
 
Registered: Oct 2004
Location: US
Distribution: Fedora Core 1
Posts: 43

Rep: Reputation: 15
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]\# "
 
Old 11-02-2004, 01:30 PM   #38
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Original Poster
Rep: Reputation: 67
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)'}\` # "
 
Old 11-02-2004, 02:46 PM   #39
cyberliche
Member
 
Registered: Aug 2004
Location: Atlanta
Distribution: Slackware 10
Posts: 85

Rep: Reputation: 15
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:

Code:
\u@\h:\w\$
 
Old 11-04-2004, 05:43 AM   #40
davholla
Member
 
Registered: Jun 2003
Location: London
Distribution: Linux Mint 13 Maya
Posts: 729

Rep: Reputation: 32
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
 
Old 01-01-2005, 11:23 PM   #41
linuxgodrh
LQ Newbie
 
Registered: Jan 2005
Posts: 5

Rep: Reputation: 0
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 files1.1Gb ->



Last edited by linuxgodrh; 01-01-2005 at 11:30 PM.
 
Old 03-26-2011, 11:56 AM   #42
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,720
Blog Entries: 29

Rep: Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930Reputation: 930
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 "
 
Old 03-27-2011, 01:03 AM   #43
tacticalbread
Member
 
Registered: Jan 2011
Location: IN
Distribution: Arch x64 multilib
Posts: 79

Rep: Reputation: 13
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/
 
Old 03-27-2011, 01:28 AM   #44
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870
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.
Old 03-27-2011, 01:37 AM   #45
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Mine is simple: nick@vega:~$
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Different name at shell prompt XJNick Linux - General 3 08-25-2005 10:20 AM
change the shell prompt ust Linux - Distributions 5 04-28-2005 03:26 PM
Shell Prompt xneowolf Linux - General 5 01-26-2003 02:06 AM
Shell prompt setup NSKL Linux - Newbie 1 06-15-2002 11:55 AM
C shell prompt robson Linux - General 2 11-12-2001 08:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration