Arch Linux Forums

Discussion forums for Arch Linux, a simple, lightweight linux distribution.

You are not logged in.

#1 2008-06-26 19:13:13

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 830
Website

What's your PS1?

On my current laptop and desktop:

Code:

PS1="\$ "     # User
PS1="# "      # Root

On my future laptop:

Code:

PS1="\[\033[1;34m\]arch\[\033[0;37m\]angel\$ "     # User
PS1="\[\033[1;34m\]arch\[\033[0;37m\]angel# "      # Root

Last edited by Barrucadu (2008-06-26 19:13:53)

Offline

 

#2 2008-06-26 19:26:04

Stythys
Member
From: California
Registered: 2008-05-18
Posts: 708
Website

Re: What's your PS1?

PS1='\[\e[1;35m\]\u\[\e[m\] \[\e[1;34m\]\W\[\e[m\] \[\e[1;31m\]> \[\e[0m\]'
PS2='>'
echo -e "                Welcome to ${bold}Arch Linux${boldoff}"
sleep 1
clear

I like to add a little welcome message tongue

To see what my prompt looks like, just take a look at My Desktop

Last edited by Stythys (2008-06-26 19:28:03)


What will you do...when the penguin finds you?

Offline

 

#3 2008-06-26 19:26:50

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 2649

Re: What's your PS1?

zsh:

Code:

PROMPT=$'%{\e[0;31m%}[%{\e[1;32m%}%*%{\e[0;31m%}][%{\e[0;32m%}%n@%m%{\e[0;31m%}]%{\e[1;31m%}%#%{\e[0m%} '
RPROMPT=$'%{\e[0;31m%}[%{\e[1;32m%}%~%{\e[0;31m%}]%{\e[0m%}'

Code:

[1:25:17][lucke@kingdom]%                                                                                                                                                           [~]

Offline

 

#4 2008-06-26 19:27:30

Allan
Developer/Forum Admin
From: Brisbane, AU
Registered: 2007-06-08
Posts: 5891
Website

Re: What's your PS1?

Code:

PS1='\n\[\033[0;32m\]\u@\h \[\033[1;33m\]\w\n\[\033[0m\]> '
PS2='\\ '

Code:

allan@arch ~
>

Offline

 

#5 2008-06-26 19:38:44

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: What's your PS1?

zsh:

Code:

PS1="%{${fg_bold[blue]}%}[%{${fg_bold[default]}%}%D%{${fg_bold[blue]}%}]-[%{${fg_bold[default]}%}%n%{${fg_bold[blue]}%}]-[${fg_bold[default]}%m%{${fg_bold[blue]}%}]-[\
%{${fg_bold[default]}%}${$(tty)#/dev/##}%}%{${fg_bold[blue]}%}]-[\
%{${fg_bold[default]}%}%~%{${fg_bold[blue]}%}]
[%{${fg_bold[default]}%}%*%{${fg_bold[blue]}%}]-%#%{${fg_bold[default]}%} "

Code:

[08-06-27]-[chi]-[tatooine]-[pts/1]-[~]
[1:34:59]-%

Last edited by chimeric (2008-06-26 19:38:59)

Offline

 

#6 2008-06-26 20:21:25

prasetyams
Member
From: Jakarta
Registered: 2008-04-28
Posts: 66

Re: What's your PS1?

user "> "
root "# "


Where's my sig?

Offline

 

#7 2008-06-27 00:30:54

.:Mr Green:.
Forum Moderator
From: U.K.
Registered: 2003-12-21
Posts: 4666
Website

Re: What's your PS1?

Code:

PS1='[ \W ] > '

Mr Green Blog

Offline

 

#8 2008-06-27 01:35:39

Purch
Member
From: Finland
Registered: 2006-02-23
Posts: 229

Re: What's your PS1?

Code:

if [ `id -u` != "0" ]; then
   PS1="${TITLEBAR}${GREEN}\u${CYAN}@${BRIGHTGREEN}\h ${CYAN}\w${WHITE} ${default}$ "
else 
   PS1="${TITLEBAR}${RED}\u${CYAN}@${BRIGHTGREEN}\h ${CYAN}\w${WHITE} ${default}$ "
fi

edit: Where does the "#" for root come from?

Last edited by Purch (2008-06-27 01:38:14)

Offline

 

#9 2008-06-27 04:01:02

B-Con
Member
From: Frisco, TX
Registered: 2007-12-16
Posts: 489
Website

Re: What's your PS1?

Code:

bash_prompt_cmd() {
        local CY="\[\e[1;36m\]" # Each is 12 chars long
        local BL="\[\e[1;34m\]"
        local WH="\[\e[1;37m\]"
        local BR="\[\e[0;33m\]"
        local RE="\[\e[1;31m\]"
        local PROMPT="${CY}$"
        [ $UID -eq "0" ] && PROMPT="${RE}#"

        # Add the first part of the prompt: username,host, and time
        local PROMPT_PWD=""
        local PS1_T1="$BL.:[ $CY`whoami`@`hostname` $BL: $CY\t $BL:$CY "
        local ps_len=$(( ${#PS1_T1} - 12 * 6 + 6 + 4 )) #Len adjust for colors, time and var
        local PS1_T2=" $BL]:.\n${PROMPT} \[\e[0m\]"
        local startpos=""

        PROMPT_PWD="${PWD/#$HOME/~}"
        local overflow_prefix="..."
        local pwdlen=${#PROMPT_PWD}
        local maxpwdlen=$(( COLUMNS - ps_len ))
        # Sometimes COLUMNS isn't initiliased, if it isn't, fall back on 80
        [ $maxpwdlen -lt 0 ] && maxpwdlen=$(( 80 - ps_len )) 

        if [ $pwdlen -gt $maxpwdlen ] ; then
                startpos=$(( $pwdlen - maxpwdlen + ${#overflow_prefix} ))
                PROMPT_PWD="${overflow_prefix}${PROMPT_PWD:$startpos:$maxpwdlen}"
        fi      
        export PS1="${PS1_T1}${PROMPT_PWD}${PS1_T2}"
}
PROMPT_COMMAND=bash_prompt_cmd

In effect, it looks like:

Code:

.:[ b-con@beacon : the-time : /working/directory ]:.
$

with colorization. I pieced it together so that I could dynamically calculate the width of the terminal and truncate the displayed working directory if it causes the total width of the line to exceed the terminal's width. (Given how I do things, this actually comes in handy every now and then.)

Last edited by B-Con (2008-06-27 04:02:19)


- "Cryptographically secure linear feedback based shift registers" -- a phrase that'll get any party started.

Offline

 

#10 2008-06-27 09:36:31

Berticus
Member
Registered: 2008-06-10
Posts: 423

Re: What's your PS1?

Purch wrote:

Code:

if [ `id -u` != "0" ]; then
   PS1="${TITLEBAR}${GREEN}\u${CYAN}@${BRIGHTGREEN}\h ${CYAN}\w${WHITE} ${default}$ "
else 
   PS1="${TITLEBAR}${RED}\u${CYAN}@${BRIGHTGREEN}\h ${CYAN}\w${WHITE} ${default}$ "
fi

edit: Where does the "#" for root come from?

http://tldp.org/HOWTO/Bash-Prompt-HOWTO
\$

Online

 

#11 2008-06-27 10:07:45

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 360

Re: What's your PS1?

Guys, ah, may I ask what this is all about...? smile

Offline

 

#12 2008-06-27 10:21:15

Barrucadu
Member
From: Hull, England
Registered: 2008-03-30
Posts: 830
Website

Re: What's your PS1?

Yes, you may ask. Would you like an answer to go with your question?

Well, PS1 is a variable set in your .bashrc that defines what your prompt looks like.

Offline

 

#13 2008-06-27 10:22:00

hrist
Member
From: Germany
Registered: 2007-01-07
Posts: 61
Website

Re: What's your PS1?

Code:

function precmd {
    export PS1="%m@%(!.%{${RED}%}%n.%{${GREEN}%}%n)% %{${WHITE}%}% %{${WHITE}%}%~ %#"
}

export RPS1="%(?..%?)"

export SPROMPT='%R is not available, maybe you fool wanted %r? '

export PS2='`_> '

preexec () {
    if [[ "$TERM" == "screen" ]]; then
    local CMD=${1[(wr)^(*=*|sudo|-*)]}
    echo -ne "\ek$CMD\e\\"
    fi
}
SELECTMIN=5

gives

Code:

moose@hrist~ %

hrist is green the rest is white
http://hrist.nonlogic.org/zshprompt.png
and I don't know why the picture isn't shown hmm

Last edited by hrist (2008-06-27 10:24:29)


hyperion - Arch64 | XMonad | nvidia or intel
theia - Ubuntu | XMonad + Gnome | nvidia

Offline

 

#14 2008-07-02 07:11:36

fumbles
Member
Registered: 2006-12-22
Posts: 209

Re: What's your PS1?

PS1='\[\033[0;31m\][\@]\[\033[0;m\][\[\033[0;34m\]\u@\[\033[0;33m\]\h\[\033[0;m\] \w]\[\033[0;32m\]\$ '
set prompt="%{^[[31m%}[%t]%{^[[m%}[%{^[[34m%}%n@%{^[[33m%}%m %{^[[m%}%~]%{^[[32m%}$ "


First is for bash, the second is for tcsh. They are the same, took me ages to do!


Don: 'The trees are already dead'

Offline

 

#15 2008-07-02 14:57:03

amdarch64
Member
Registered: 2008-06-01
Posts: 67

Re: What's your PS1?

mine is very simple, but i do have a problem with text overflow going over what i had typed. if i could get some help with that ?
in .bashrc :

export PS1='\[\e]2; \d, \@ | Arch64\a\]\u \w $ '


freetards and fosstards visit http://linuxhaters.blogspot.com/

Offline

 

#16 2008-07-02 16:28:02

XFire
Member
From: UK
Registered: 2008-05-11
Posts: 175

Re: What's your PS1?

PS1='\[\e[0;36m\]\h\[\e[m\]-\[\e[0;37m\]\u\[\e[m\]\[\e[0;37m\] \w:
> '

Is mine


There is a difference between bleeding [edge] and haemorrhaging. - Allan

Offline

 

#17 2008-07-02 19:48:13

11010010110
Member
Registered: 2008-01-14
Posts: 284

Re: What's your PS1?

PS1="\u \W "

Offline

 

#18 2008-07-03 00:04:57

pauldonnelly
Member
Registered: 2006-06-19
Posts: 762

Re: What's your PS1?

Code:

export PS1=$'%{\e[0;36m%}%?%.%#%{\e[0;0m%}'
export PS2=$'%{\e[0;36m%}%?%.%{\e[0;0m%}> '

For zsh. It looks awful, but it's really just the return value of the last command, the current directory (sans path), and a %, all in cyan.

Offline

 

#19 2008-07-03 00:55:42

czar
Member
Registered: 2008-03-08
Posts: 115

Re: What's your PS1?

This is what i used to have:
green smile when command is succesful and a red frown when it fails

Code:

bash_prompt_command() {
RTN=$?
smiley=$(smiley $RTN)
smileyc=$(smileyc $RTN)
}
PROMPT_COMMAND=bash_prompt_command
            
smiley() {
if [ $1 == 0 ] ; then
echo ":)"
else
echo ":("
fi
}
smileyc() {
if [ $1 == 0 ] ; then
echo $GREEN
else
echo $RED
fi
}
                                                                    
if [ $(tput colors) -gt 0 ] ; then
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
RST=$(tput op)
fi
PS1="\[\$smileyc\]\$smiley\[$RST\] \$ "

but now i've combined it (see: hacked it together) with B-con's lovley script:\

Code:

bash_prompt_cmd() {
RTN=$?



smiley() {
    if [ $1 == 0 ] ; then
echo ":)"
    else
echo ":("
       fi
    }
smileyc() {
    if [ $1 == 0 ] ; then
echo $GREEN
else
echo $RED
       fi
    }
 if [ $(tput colors) -gt 0 ] ; then
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
RST=$(tput op)
fi
smiley=$(smiley $RTN)
smileyc=$(smileyc $RTN)
        local CY="\[\e[1;31m\]" # Each is 12 chars long
        local BL="\[\e[1;34m\]"
        local WH="\[\e[1;37m\]"
        local BR="\[\e[0;33m\]"
        local RE="\[\e[1;31m\]"
        local PROMPT="${CY}$"
        [ $UID -eq "0" ] && PROMPT="${RE}#"

        # Add the first part of the prompt: username,host, and time
        local PROMPT_PWD=""
        local PS1_T1="$BL.:[ $CY`whoami`@`hostname` $BL: $CY\t $BL:$CY "
        local ps_len=$(( ${#PS1_T1} - 12 * 6 + 6 + 4 )) #Len adjust for colors, time and var
        local PS1_T2=" $BL]:.\n\[\$smileyc\]\$smiley\[$RST\] " 
        local startpos=""

        PROMPT_PWD="${PWD/#$HOME/~}"
        local overflow_prefix="..."
        local pwdlen=${#PROMPT_PWD}
        local maxpwdlen=$(( COLUMNS - ps_len ))
        # Sometimes COLUMNS isn't initiliased, if it isn't, fall back on 80
        [ $maxpwdlen -lt 0 ] && maxpwdlen=$(( 80 - ps_len )) 

        if [ $pwdlen -gt $maxpwdlen ] ; then
                startpos=$(( $pwdlen - maxpwdlen + ${#overflow_prefix} ))
                PROMPT_PWD="${overflow_prefix}${PROMPT_PWD:$startpos:$maxpwdlen}"
        fi      
        export PS1="${PS1_T1}${PROMPT_PWD}${PS1_T2}"
}
PROMPT_COMMAND=bash_prompt_cmd

Offline

 

#20 2008-07-03 02:21:59

Square
Member
Registered: 2008-06-10
Posts: 328

Re: What's your PS1?

Code:

PS1='\[\033[1;31m\]\W/\[\033[0m\] '

Simplicity.

Last edited by Square (2008-07-03 02:22:12)


A little note:

Offline

 

#21 2008-07-03 07:42:20

iphitus
Developer
From: Melbourne, Australia
Registered: 2004-10-08
Posts: 4901
Website

Re: What's your PS1?

mine's just user@machine, and a different colour for laptop, desktop, ssh, root.

Offline

 

#22 2008-07-03 08:32:28

SiD
Member
From: Germany
Registered: 2006-09-21
Posts: 413

Re: What's your PS1?

user
PS1='[\[\033[1;36m\]\u\[\033[0m\]@\h \W]\$ '

root
PS1='[\[\033[1;31m\]\u\[\033[0m\]@\h \W]\$ '


"To start press any key." Where's the any key? - Homer Simpson

Offline

 

#23 2008-07-03 08:35:40

catwell
Member
From: Bretagne, France
Registered: 2008-02-19
Posts: 206
Website

Re: What's your PS1?

[\a \w]

Offline

 

#24 2008-07-03 14:13:10

synorgy
Member
Registered: 2005-07-11
Posts: 166

Re: What's your PS1?

Code:

\@ \[\033[0;32m\] \w\[\033[0m\] >

Code:

2:05 PM ~ >

The working directory portion is in green.

Last edited by synorgy (2008-07-03 14:13:33)


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity."
--Dennis Ritchie

Offline

 

#25 2008-07-03 21:12:57

tigrmesh
Member
From: Florida, US
Registered: 2007-12-11
Posts: 753

Re: What's your PS1?

Square wrote:

Code:

PS1='\[\033[1;31m\]\W/\[\033[0m\] '

Simplicity.

What a great idea!  Do I really need to see the full path of every directory I'm in?  ...No...

Offline

 

Board footer

Powered by FluxBB