Skip to content

61 comments

Mine is weird. It takes up two lines, and it changes its color based on a hash of $(whoami)@$(hostname):$(pwd -P), the idea being that two prompts in different directories or on different hosts will end up with different colors.

_prompt_colors=(0 1 2 3 4 5 6)
_prompt_styles=(0 1 3 4)
_hashcolor() {
    hash=$(echo -n "$1" | md5sum)
    color_index=$(( 0x${hash:0:8} % ${#_prompt_colors[@]} ))
    style_index=$(( 0x${hash:8:8} % ${#_prompt_styles[@]} ))
    color=${_prompt_colors[color_index]}
    style=${_prompt_styles[style_index]}
    if (( color == 0 && style == 0 )); then 
        color=2
        style=4
    fi 
    echo -E "\e[${style};3${color}m"
}

color='$(echo -e $(_hashcolor "$(whoami)@$(hostname):$(pwd -P)"))'
reset='\[\e[0m\]'
export PS1="▶▶▶ ${color}\u@\h${reset}:${color}\W${reset}${git_ps1}\n[\j]\\$ "

Looks like this:

▶▶▶ kalgynirae@fruitron:~
[0]$ 

The 0 is the number of background jobs which is super useful for me because I background things all the time with Ctrl+z.

6 points
function fish_mode_prompt
# Do nothing if not in vi mode
  if set -q __fish_vi_mode
    switch $fish_bind_mode
      case default
	    prompt_segment $grey $green "N"
      case insert
	    prompt_segment $grey $white "I"
      case replace-one
	    prompt_segment $grey $red "R"
      case visual
	    prompt_segment $grey $purple "V"
    end
  end
end    

For fish with vi mode enabled and omf installed.

Here is a picture of it

5 points
export PS1="\[${color_LINS}\]┌─\[${color_BARS}\][\[${color_USER}\]\u\[${color_ATSG}\]@\[${color_HOST}\]\h\[${color_BARS}\]]\[${color_LINS}\]──\[${color_BARS}\][\[${color_CDIR}\]\w\[${color_BARS}\]]\n\[${color_LINS}\]└──\[${color_BNCH}\]\$(__git_ps1 '(%s)\[${color_LINS}\]──')\[${color_PROM}\]\[\$(parse_git_dirty)\]>>\[${color_NOCL}\]\${exitS} "

typical view

unhappy face for non-zero exit of prev command

in a git directory. __git_ps1 for branch name, etc. Arrow color is green for clean git status, yellow for unstaged changes, or staged but not commited changed (basically git status --porcelain).

4 points
export PS1="\[$(tput bold)\]\[$(tput setaf 6)\]\t \[$(tput setaf 2)\][\[$(tput setaf 5)\]\u\[$(tput setaf 3)\]@\[$(tput setaf 5)\]\h \[$(tput setaf 6)\]\W\[$(tput setaf 2)\]]\[$(tput setaf 4)\]\\$ \[$(tput sgr0)\]\[$(tput sgr0)\]"

picture of it

4 points

My prompt is basically a modified version of /usr/share/zsh/functions/Prompts/prompt_walters_setup. http://imgur.com/jIZaA3Y

Left Application non-zero return code (if unsuccessful) -- code bold white, brackets grey. User: normal -- bold white, root -- bold red. Everything else is grey:

[127] user@hostname $

Right Cwd in grey

~/Documents

PS1='%(?..%F{7}[%f%B%?%b%F{7}]%f )%B%(!.%F{1}.%F{reset})%n%f%b%F{7}@%m %(!.#.$)%f '
RPROMPT='%F{7}%~%
3 points

LPS1:

PROMPT=$'%n@%m:%~%(?..[%?]) %h %# '

RPS1:

# If inside a Git repository, print its branch and state
git_prompt_string() {
  local git_where="$(parse_git_branch)"
  [ -n "$git_where" ] && echo "$GIT_PROMPT_SYMBOL$(parse_git_state)$GIT_PROMPT_PREFIX%{$fg[yellow]%}${git_where#(refs/heads/|tags/)}$GIT_PROMPT_SUFFIX"
}

# Set the right-hand prompt
RPS1='$(git_prompt_string)'%                                    
3 points

http://imgur.com/h8sa0eg it's completely dynamic, if i'm in git repo it shows on which branch I am and in which state the commits are. The last one is prompt for root, I've spent a lot of time jumping from one machine to another, so the red hostname is pretty important :)

2 points

Okay, I've been trying for that line above my prompt for a bit -- how'd you do it? It looks great! (OR are those tmux splits?)

1 points

I really like the look of this. Is there anyway that you could help a noob like me set my terminal up to look like that. I don't need to the tmux stuff.

1 points

PS1:

\[\e[0;35m\]\t \[\e[0;34m\]\u@\h \[\e[0;32m\]\W\[\e[0m\]

looks like this:

12:48:55 gx@gx-arch gx $

time is magenta, user@host is blue, pwd is green

Edit: I hate this Editor from reddit...

2 points

I just use the grml config for zsh. This is what is used on the archiso. I've made a couple of negligible tweaks.

2 points

From my .zshrc:

# Git prompt
local gitval='$(__git_ps1 " (%s)")'
source /usr/share/git/completion/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"

# Custom prompt
PROMPT="%B%T%b [%{$fg_bold[red]%}%?%{$reset_color%}]%{$fg_no_bold[green]%}${gitval}%{$reset_color%} %# "
RPROMPT="%{$fg_no_bold[green]%}%~%{$reset_color%}"

(screenshot)

Basically, on the left it just prints the time and the exit code of the last command, and on the right it prints the current working directory. It also prints special stuff if I'm in a git repo. And everything is colorized.

(It's similar to the gmrl prompt from the archiso.)

I choose not to include my user name or host name because this is for my personal laptop, which I'm the only one who uses, and which I never remotely ssh into.

2 points

export PS1='[\e[1;34m][[\e[m] [\e[1;32m]\u[\e[m][\e[1;34m]@[\e[m][\e[1;37m]\h[\e[m] [\e[1;34m]][\e[m][\e[1;34m][[\e[m] [\e[1;37m]<[\e[m][\e[1;32m]\w[\e[m][\e[1;37m]>[\e[m] [\e[1;34m]][\e[m][\e[1;37m]:[\e[m][\e[1;32m]#[\e[m] '

Edit: This was copy/pasta'd straight from my user .bashrc, not sure why it wouldn't work for anyone else

1 points

I got the following output:

[][[] []glysolid[][]@[][]Workstation_404[] []][][][[] []<[][]~[][]>[] []][][]:[][]#[]
2 points
export PS1='\[\e[1;34m\][\[\e[m\] \[\e[1;32m\]\u\[\e[m\]\[\e[1;34m\]@\[\e[m\]\[\e[1;37m\]\h\[\e[m\] \[\e[1;34m\]]\[\e[m\]\[\e[1;34m\][\[\e[m\] \[\e[1;37m\]<\[\e[m\]\[\e[1;32m\]\w\[\e[m\]\[\e[1;37m\]>\[\e[m\] \[\e[1;34m\]]\[\e[m\]\[\e[1;37m\]:\[\e[m\]\[\e[1;32m\]#\[\e[m\] '

That should work.

1 points

Prefix your comment with four spaces, the backslashes got eaten.

1 points
function fish_prompt
    set -g c_color1 (set_color FFFF00)
    set -g c_color2 (set_color 00FF00)
    set -g c_color3 (set_color 00FFFF)
    set -g c_color4 (set_color FFFFFF)
    echo "$c_color2┌─[$c_color1"$USER\@(hostname -f)"$c_color2]─[$c_color4"(pwd)"$c_color2]"
    echo "$c_color2└─[$c_color3"(date +%H:%M)"$c_color2]\$ "
end
1 points

For all non-root-users:

export PS1='\[\e[1;37m\]\u\[\e[0m\]@\[\e[1;36m\]\h\[\e[0m\] \[\e[1;34m\][\w]\[\e[0m\]'

glysolid@Workstation_404 [~]

 

For root:

export PS1='\[\e[1;31m\]\u\[\e[0m\]@\[\e[1;36m\]\h\[\e[0m\] \[\e[1;34m\][\w]\[\e[0m\]'

root@Workstation_404 [/etc/kernel/]

 

Edit: I hate this Editor from reddit...

1 points
unknown author

Deleted before we saved it.

1 points
unknown author

Deleted before we saved it.

1 points

Nothing too special:

[[ $EUID == 0 ]] && c='\[\e[1;31m\]' || c='\[\e[1;32m\]'
PS1="${c}[\u] [\w]\n  >\[\e[0m\] "
unset c

Looks like this (green for normal user, red for root):

[james] [~]
  >
1 points
privilege_color() {
    local groups
    groups=($(groups))
    if [[ -n ${groups[(r)wheel]} || -n ${groups[(r)sudo]} ]]
    then
        echo yellow
    else
        echo cyan
    fi
}

PS1="%B%F{black}%m%b %(!,%F{red},%F{$(privilege_color)})%1~❯%0f "

(zsh)

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.