LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 02: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, 06:37 PM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: pclinuxos slackware64 tails kali
Posts: 3,372
Blog Entries: 33

Rep: Reputation: 217Reputation: 217Reputation: 217
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 06: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 07:21 AM
I'd like to change the default shell prompt. lynnevan Linux - General 9 09-08-2011 08:00 AM
How to change the default shell in Linux apdas Linux - Newbie 2 11-11-2009 11:11 AM
How to change the default shell to bash? shadkong Slackware 12 04-23-2005 03:49 PM
How to change default root shell fessin Linux - General 2 02-13-2003 11:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:30 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