LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-31-2012, 03:24 PM   #1
Vryali
LQ Newbie
 
Registered: Oct 2010
Location: Columbia, SC
Distribution: Arch Linux
Posts: 11

Rep: Reputation: Disabled
ZSH - Change default non-root shell symbol from % to $?


Currently have a zshrc that has an if statement to set prompt symbol and I just refrain from using the %# when setting things. Was just curious if there's a built-in way to change it so it's the more normal #/$ or if I'm stuck with the if check.

Cheers,
 
Old 07-31-2012, 07:37 PM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Posts: 3,366
Blog Entries: 33

Rep: Reputation: 216Reputation: 216Reputation: 216
Hi, I have an example that adds colour and different prompt symbols for user and root.

I can't reference the script, lost/forgot.

here is part of,
~/.zshrc....
Code:
# Set a colour prompt #  home
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
    colors
fi
    for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
        eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
        eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
        (( count = $count + 1 ))
    done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
if [ `whoami` = 'root' ]; then
    PS1="$PR_RED%n$PR_NO_COLOR@$PR_BLUE%m%u$PR_NO_COLOR:$PR_CYAN%2c$PR_RED%(!.#.$) "
else
    PS1="$PR_GREEN%n$PR_NO_COLOR@$PR_BLUE%m%u$PR_NO_COLOR:$PR_CYAN%2c$PR_YELLOW%(!.#.$) "
fi
# Put a clock on the right hand prompt
RPS1="$PR_CYAN(%D{%d-%m %H:%M})$PR_NO_COLOR"
looks like this...
Code:
glenn@GamesBox:~$ su                                                                                    (01-08 09:39)
root@GamesBox:~#                                                                                        (01-08 09:39)
You can add this to the root .zshrc as well.

Hope this helps, for more about zshell and it's use, look up "bash2zsh", "Jerry Peek" https://www.coderanch.com/t/93722/Bo...r-Kiddle-Jerry

And Jerry peek's Magazine articles.

Cheers Glenn

Last edited by GlennsPref; 07-31-2012 at 07:45 PM. Reason: check formatting
 
1 members found this post helpful.
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to change the default shell? Ajit Gunge Linux - Newbie 1 05-22-2012 08:21 AM
I'd like to change the default shell prompt. lynnevan Linux - General 9 09-08-2011 09:00 AM
How to change the default shell in Linux apdas Linux - Newbie 2 11-11-2009 12:11 PM
How to change the default shell to bash? shadkong Slackware 12 04-23-2005 04:49 PM
How to change default root shell fessin Linux - General 2 02-14-2003 12:25 AM


All times are GMT -5. The time now is 12:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration