Comments on: My ZSH Prompt https://pthree.org/2008/01/31/my-zsh-prompt/ Linux. GNU. Freedom. Tue, 31 Oct 2017 18:00:46 +0000 hourly 1 https://wordpress.org/?v=5.0-alpha-42127 By: Aaron https://pthree.org/2008/01/31/my-zsh-prompt/#comment-110804 Tue, 13 Apr 2010 14:54:38 +0000 http://pthree.org/?p=544#comment-110804 @Brianskywalker I can't reproduce your prompt. I just get a series of double quotes. On the other hand, I like adding an ASCII fish to the prompt. I need more of a playful prompt.

]]>
By: Brianskywalker https://pthree.org/2008/01/31/my-zsh-prompt/#comment-110801 Tue, 13 Apr 2010 07:47:54 +0000 http://pthree.org/?p=544#comment-110801 > cd /usr/share/doc/zsh/
>

local pscolor="%B%(?,%F{green},%F{red})"
PS1="${pscolor}> %f%b"
PS2="${pscolor}> %f%b"
RPROMPT="(%!%) %T"

A very simple ascii art fish, used as a ps1. The eye is actually the pwd, and the fish turns red when the last command returns an error. I also have a right-aligned prompt with the history event number and time.

This is somewhat novel but very useful.

]]>
By: Erus_Iluvatar https://pthree.org/2008/01/31/my-zsh-prompt/#comment-110626 Fri, 08 Jan 2010 17:37:35 +0000 http://pthree.org/?p=544#comment-110626 PS1="%(!.#.$) "
RPROMPT="%(?..%F{red}!%?!%F%F{white}:)%~%(1j.:%j.)"

Simple and powerfull.

]]>
By: James https://pthree.org/2008/01/31/my-zsh-prompt/#comment-109287 Wed, 07 Jan 2009 00:42:03 +0000 http://pthree.org/?p=544#comment-109287 # Git branch
function __prompt_git() {
local git_dir ref br top;
git_dir=$(git rev-parse --git-dir 2> /dev/null) || return
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
br=${ref#refs/heads/}
top=$(cat $git_dir/patches/$br/current 2>/dev/null) && top="/$top"
echo "($br$top)"
}

# Colour stuff
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]%}"

# Environment variables
PS1="$PR_LIGHT_BLUE%m$PR_NO_COLOR:$PR_LIGHT_WHITE%2c$PR_NO_COLOR %n%(!.#.$) "
RPS1="$PR_LIGHT_RED$(__prompt_git)$PR_NO_COLOR $PR_LIGHT_YELLOW%D{%H:%M}$PR_NO_COLOR !%h"

Lovely little prompt. Looks kinda like…

osx:~ james$ (master) 00:38 !61

…but with lots of pretty colours! 😮

I'm mainly posting because I want a Mac with Safari on the comment list!

]]>
By: Redd Vinylene https://pthree.org/2008/01/31/my-zsh-prompt/#comment-108954 Sun, 07 Dec 2008 11:13:39 +0000 http://pthree.org/?p=544#comment-108954 Hello Aaron! What you think of this?

-

if [[ `whoami` = root ]] then

a1="%{$fg_bold[red]%}"

a2="%{$fg_no_bold[red]%}"

else

a1="%{$fg_bold[white]%}"

a2="%{$fg_no_bold[white]%}"

fi

PROMPT="$a1(%n@%m)$a2(%D{%d/%m}+%D{%H:%M})"$'\n'

PROMPT+="$a2(%~) %{$reset_color%}"

-

Do let me know!

]]>
By: mjg https://pthree.org/2008/01/31/my-zsh-prompt/#comment-101726 Fri, 30 May 2008 20:51:43 +0000 http://pthree.org/?p=544#comment-101726 this is in my .zshrc:

local smiley="%(?,%{$fg[green]%}:%)%{$reset_color%},%{$fg[red]%}:(%{$reset_color%})"
PROMPT=$'%{\e[0;36m%}%B[%b%{\e[0m%}%B%n%b%{\e[0;36m%}%B@%b%{\e[0m%}%B%m%b%{\e[0;36m%}%B]%b%{\e[0;36m%}%B[%b%{\e[0m%}%B${smiley}%b%{\e[0;36m%}%B]%b%{\e[0m%}%B%#%b

looks like this:

[user@host][:)] % cd sh
[user@host][:)] % ls foo
ls: cannot access foo: No such file or directory
[user@host][:(] %

It will show a green smiley if the last command finished successfully, or a red frowney if it did not.

]]>
By: Anonymous bin Ich https://pthree.org/2008/01/31/my-zsh-prompt/#comment-95654 Fri, 04 Apr 2008 17:02:23 +0000 http://pthree.org/?p=544#comment-95654 ___________________

PROMPT=$'%(?..%{\e[41;38m%}%B-%?-%b%{\e[0m%} )%(1j.%{\e[01;33m%}[%j] .)%{\e[01;32m%}%m%{\e[0m%} %{\e[01;36m%}%2~%{\e[0m%} %B%#%b '
RPROMPT=$'%{\e[00;07m%}%(?..$exitstuff)% %{\e[0m%} %T'

# Taken and modified from "atom's .zshrc" public release v0.109 - http://smasher.org/zsh/
precmd () {
local exitstatus="${?}"
if [[ ${exitstatus} -ge 128 && $exitstatus -le (127+${#signals}) ]]; then
# Last process was killed by a signal. Find out what it was from
# the $signals environment variable.
exitstuff="${signals[${exitstatus}-127]}"
else
unset exitstuff
fi
}

___________________
The function here tells you the name of the interrupt, which I like 🙂
Also, RPROMPT tells the time in reverse video, so no problem while testing different themes etc. Although I am planning to switch it to the left so that copy-pasting can become easier 🙂

]]>
By: Hobbsee https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90394 Fri, 01 Feb 2008 09:50:19 +0000 http://pthree.org/?p=544#comment-90394 Thanks thom! I'd been wondering about a different remote prompt! Mine now is:

if test `whoami` != "root"
then
PS1="${fg_light_cyan}%B%n@%m:${fg_light_blue}%~${fg_light_gray}%#%b "
else
PS1="${fg_red}%B%n@%m:${fg_red}%~${fg_light_gray}%#%b "
fi
RPROMPT="${fg_cyan}%t${fg_no_colour}"

]]>
By: Glenn https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90324 Thu, 31 Jan 2008 21:51:50 +0000 http://pthree.org/?p=544#comment-90324 My PS1 prompt is pretty basic:
PS1=%B%m%b >

but what I really like is the right justified prompt which is where I display the current directory...

RPROMPT=%~

]]>
By: Seth https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90316 Thu, 31 Jan 2008 19:33:49 +0000 http://pthree.org/?p=544#comment-90316 I can respect that you don't like multi-line prompts (sometimes they can really get in the way, or make the terminal look *super* busy (the clint theme is three (!) lines)). In spite of that, here's a quick note about the bad default colors:

prompt clint blue cyan white yellow white
prompt -h clint

Regardless, nice writeup of a simple and elegant prompt.

]]>
By: Scott Robertson https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90309 Thu, 31 Jan 2008 18:45:30 +0000 http://pthree.org/?p=544#comment-90309 PROMPT=$'%(!.%{\e[1;31m%}.%{\e[1;32m%})%n@%{\e[1;34m%}%m:%{\e[1;31m%}%1~%{\e[1;00m%}%(!.#.$)'
RPROMPT='%(?..%?)'

name@host:(last element of pwd)$
At far right is the exit code if not 0.
Colors make it a bit hard to read.

]]>
By: eddie https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90302 Thu, 31 Jan 2008 17:07:16 +0000 http://pthree.org/?p=544#comment-90302 What is ZSH?

cool dude. We are heading to a momentum when everybody can handle xorg.conf or grub but doesn't know what bash is.

computer illiterates ftw!

PS: copying your $PS1 to my ~/.bashrc at light speed

]]>
By: My ZSH Prompt https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90300 Thu, 31 Jan 2008 16:22:33 +0000 http://pthree.org/?p=544#comment-90300 [...] unknown wrote an interesting post today onHere’s a quick excerptaaron@kratos:~ 262 % ls -ld tmp drwxrwxr-x 2 aaron root 4096 2008-01-30 13:22 tmp aaron@kratos:~ 263 % rm -rf tmp aaron@kratos:~ 264 % ls -ld tmp ls: tmp: No such file or directory aaron@kratos:~[2] 265 % echo $? 2 aaron@kratos:~ 266 % … [...]

]]>
By: Smarter https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90298 Thu, 31 Jan 2008 16:12:16 +0000 http://pthree.org/?p=544#comment-90298 [smarter@fenny ~/Builds/revu/extremetuxracer]% echo $PS1
%{$reset_color$bold_color$fg[green]%}[%{$reset_color$reset_color$fg[green]%}%n%{$reset_color$bold_color$fg[green]%}@%{$reset_color$reset_color$fg[green]%}%m%{$reset_color$bold_color$fg[green]%} %{$reset_color$reset_color$fg[cyan]%}%~%{$reset_color$bold_color$fg[green]%}]%{$reset_color$reset_color$fg[green]%}%# %{$reset_color$reset_color%}
Clean and green (:

]]>
By: Tuxero https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90293 Thu, 31 Jan 2008 15:17:02 +0000 http://pthree.org/?p=544#comment-90293 What is ZSH?
This is the first time I hear about it.
Cheers mate!

]]>
By: Thom May https://pthree.org/2008/01/31/my-zsh-prompt/#comment-90292 Thu, 31 Jan 2008 15:02:10 +0000 http://pthree.org/?p=544#comment-90292 if [[ -n $SSH_CLIENT || -n $REMOTEHOST ]] then
PS1=': ${CHROOT}%T %(5~|.../%2c|%~) %# '
RPROMPT=%n@%m
else
PS1=': ${CHROOT}%T %(5~|.../%2c|%~) %# '
fi

]]>