LinuxQuestions.org
Register a domain and help support LQ
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
 
LinkBack Search this Thread
Old 11-12-2003, 05:00 PM   #1
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
What does your shell prompt look like?


Well we have a thread for screen shots so waht about your shell prompt?

There are lots of examples on the net including ones that show load averages etc so I just wondered what other people used.

I'll start off with my default one:
Code:
rossy - Wed Nov 12 22:57:01
~> cd /usr/src/linux
rossy - Wed Nov 12 22:57:06
/usr/src/linux>
The prompt string is:
PS1="\[\033[0;31m\]\u - \d \t\n\w> \[\033[0m\]"

Please try and include any commands/scripts etc you used to get your prompt.
 
Old 11-12-2003, 05:04 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 194Reputation: 194
Mines simple and probably standard:

Code:
drew@trickykid:/etc$
The prompt string is:
PS1='\u@\h:\w\$ '
 
Old 11-12-2003, 05:50 PM   #3
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 682

Rep: Reputation: 62
Here's my prompt string...
PS1="[\u@\h \w]--> "

shows up like this:
[blinky@Spork ~]-->
 
Old 11-12-2003, 06:28 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Code:
|--j@slackmagick bash 2.05b (1) Wed Nov 12 19:26:51
|--~ >>
Code:
PS1='\n|--\u@\h \s \v (\l) \d \t\n|--\w >> '
 
Old 11-12-2003, 09:58 PM   #5
m0rl0ck
Member
 
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
[[@bunny:17:54:17:root]]

But you dont get the full effect without the color, try it out:

PS1="\[\033[1;30m\]\[\033[0;32m\][\[\033[1;32m\][\[\033[1;35m\]\[\033[1;36m\]@\h
\[\033[1;37m\]:\[\033[1;35m\]\t\[\033[1;37m\]:\[\033[1;36m\]\W\[\033[1;32m\]]\[\
033[0;32m\]]\[\033[1;30m\]]\[\033[0;0m\]"

Make sure you get the line returns out.

This is my firewall:
[@m0rl0ck:22:57:15:root]+>

Some what the same but uses reverse video, heres the $PS1:

PS1="[\[\033[1;36m\]@\[\033[0;45m\]\h:\[\033[1;36m\]\t\[\033[0;44m\]\[\033[1;36m
\]:\W\[\033[0m\]]\[\033[1;31m\]+>\[\033[0m\]"


EDIT: HEY!! I just realized my clocks are either out of sync or it took me 5 hours 3 mins to compose this post

Last edited by m0rl0ck; 11-12-2003 at 10:01 PM.
 
Old 11-12-2003, 10:02 PM   #6
green_dragon37
Member
 
Registered: Oct 2002
Location: Lower Alabama
Distribution: Slackware, OpenBSD 3.9
Posts: 344

Rep: Reputation: 31
I use ctrl+Z alot, so:

0 [321-2]
[Wed Nov 12 22:02:47]
green_dragon37@grndrgn001 / >

PS1 = \j [\!-\#]\n[\d \t]\n\u@\h \W >
 
Old 11-13-2003, 05:18 AM   #7
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
For regular users: (I have a rather colorful hostname, so I edited it somewhat for this post)

cerbere@s#|thead:~$
PS1='\u@\h:\w\$ '

For root:

root@s#|thead:~#
PS1='\[\033[1;31m\]\u@\h\[\033[1;33m\]:\w\[\033[0m\]\$ '

This changes the color of 'root@hostname' to bright red, and the color of the pwd to bright yellow. That way I'm less likely to do things as root that I really don't want to do.

Enjoy!
--- Cerbere
 
Old 11-13-2003, 09:23 AM   #8
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
It depens on the way I've been logged into the system :-D

normal user: me@pts/1 foldername $

root user: root@pts/1 foldername $

and remotely, me@hal9000 foldername $

The title of the xterm / konsole will also display the tty, host, and full path name. (only the last folder is shown in the prompt)

Code:
#!/bin/bash

PS1='\u@\h:\w\$ '

if [ "$TERM" = "xterm" -o "$TERM" = "xrvt" -o "$TERM" = "$SCREEN" ]; then
  ## Only update the title in an xterm.
  PS1_TITLE='\[\e]2;\u@\H:pts/\l \w\a'
# PS1_TITLE='\[\e]2;\u@\H \w\a\e[32;1m\]>\[\e[0m\]'
else
  PS1_TITLE=''
fi


if [ -z "$SSH_CONNECTION" ]; then

  # local, don't display host, but tty device.

  PS1_TTY="`tty | sed -e 's/\/dev\///'`"

  if [ "`id -u`" = "0" ]; then
    # Red root prompt
    PS1_USER='\[\033[1;31m\]\u'
    PS1_AT='\[\033[0;31m\]@'
    PS1_HOST='\[\033[1;31m\]'
  else
    # Green user prompt
    PS1_USER='\[\033[1;32m\]\u'
    PS1_AT='\[\033[0;32m\]@'
    PS1_HOST='\[\033[1;32m\]'
  fi

  PS1_HOST="$PS1_HOST$PS1_TTY"
  unset -v PS1_TTY

else

  # SSH connection, different color and display host.

  if [ "`id -u`" = "0" ]; then
    # Red/gray root prompt
    PS1_USER='\[\033[1;31m\]\u'
    PS1_AT='\[\033[0;31m\]@'
  else
    # green/gray user prompt
    PS1_USER='\[\033[1;32m\]\u'
    PS1_AT='\[\033[0;32m\]@'
  fi
  PS1_HOST='\[\033[1;30m\]\h'
fi

PS1_PATH='\[\033[1;34m\]\W'  # show dir in blue
PS1_RESET='\[\033[0m\]'


# concatenate.

PS1="$PS1_TITLE$PS1_USER$PS1_AT$PS1_HOST$PS1_RESET $PS1_PATH \\$ $PS1_RESET"
unset -v PS1_TITLE PS1_USER PS1_AT PS1_HOST PS1_PATH PS1_RESET

#PS1='\033]2;\w\007\[\033[1;32m\]\u@\h \[\033[1;34m\]\W \$ \[\033[0m\]'


# Other magical prompts:

PS2='> '
PS4='\[\033[0;34m\]+\[\033[0m\] '

export PS1 PS2 PS4
 
Old 11-14-2003, 05:46 AM   #9
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 12.04, Fedora 17, Mint 16, Chakra
Posts: 3,618

Rep: Reputation: Disabled
Hey, interested noobs (like me)

Note, that PS1 (the control-string for your prompt) can be set at differing places for different users on your system. Here is what I could make out (without actual access to my system):

/etc/bashrc is used to set the prompt for the "true" consoles reached via <Alt><Crtl><Function key 1 through 6>

/root/bashrc is used to set the prompt for root with graphical login (under KDE)

/home/user/bashrc is used to set the prompt for user (your user-id here)

Please note, that some systems place a "." (without the "'s) in leading position of bashrc, thus generating .bashrc (dot-bashrc), which might be hidden in the file manager (activate "show hidden files") and to the ls-command (that's a small "L") so use the -a option (ls -a).

I do not know where PS2, PS3 ... PSN are set and what they are good for, exactly. Any takers?

@moderators (and gurus): checking and editing this post directly as necessary for errors and improvements is welcome.
 
Old 11-14-2003, 08:03 AM   #10
yapp
Member
 
Registered: Apr 2003
Location: Netherlands
Distribution: SuSE (before: Gentoo, Slackware)
Posts: 613

Rep: Reputation: 30
PS2 is your secondary prompt, if you enter commands on multiple lines. for example, if statements, or while loops. (they require a 'counterpart'; a command that ends the statement)
PS4 is used if you enable "set -x", which shows all commands being executed.


from the bash manual you'll see what files are used. (just type "G" to skip to the end) files in /etc/ are usually global, and affect everyone using bash. files in your home directory overrule these global settings.

if you run bash from a login session (or bash -l), /etc/profile will be read, and from your home direcory: ~/.bash_profile, or ~/.profile.

In slackware, there is a /etc/profile.d/ directory where all *excutable scripts* are being executed by /etc/profile too. Some distributions don't have this, but you could add a few lines at the end of /etc/profile very easy:
Code:
# Append any additional sh scripts found in /etc/profile.d/:
for file in /etc/profile.d/*.sh ; do
  if [ -x $file ]; then
    source $file
  fi
done
...guess once, by bash prompt color script is located at /etc/profile.d/bash-prompt-color.sh this affects all users.

a script can be made executable with this command:
chmod +x <insert filename here>

Last edited by yapp; 11-14-2003 at 08:07 AM.
 
Old 11-14-2003, 12:37 PM   #11
cwolf
Member
 
Registered: Mar 2003
Location: Switzerland
Distribution: Sun Solaris 7/8/9, Fedora Core 3
Posts: 63

Rep: Reputation: 15
For users: <user>@<host>$
and for root: <user>@<host>#
 
Old 11-14-2003, 03:23 PM   #12
schatoor
Senior Member
 
Registered: Jul 2002
Location: a tiny place caled hendrik ido ambacht in the netherlands
Distribution: SuSE, debian, slackware, lfs
Posts: 1,358

Rep: Reputation: 45
mine is simple :

Code:
[sohail@linux /usr/local]$ echo $PS1
\[\033[37;01m\][\u@\h \w]$ \[\033[00m\]
[sohail@linux /usr/local]$
 
Old 11-14-2003, 04:23 PM   #13
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
[17:20:06] slight - slight>

Errr.... this is from memory, so no guarantees if it's wrong (which it probably is):

export PS1="\e[36;1m]\t\e[0m]\u - \w>"

slight
 
Old 11-16-2003, 06:51 PM   #14
pibby
Member
 
Registered: Oct 2003
Location: Houston, TX
Distribution: Debian Sid
Posts: 100

Rep: Reputation: 15
Cool stuff guys, but one quick question...
Mine is the standard pibby@localhost thing and I am wondering how I change the "localhost" part. For instance TrickyKid has drew@trickykid. Local host is so boring, I hope there is a way to change that.
Thanks in advance for any help you can offer
 
Old 11-16-2003, 09:33 PM   #15
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Rep: Reputation: 30
Well, you could either change your actual hostname, or just use some of these tricks posted here. I am not positive about Mandrake, but I know in Slack there is a HOSTNAME file in /etc that you can edit to change it from localhost. I actually used netconfig, but I think thats a Slack-specific script.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 07:52 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration