Skip to content

Instantly share code, notes, and snippets.

@gurgeh
Created September 28, 2012 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gurgeh/3800072 to your computer and use it in GitHub Desktop.
Save gurgeh/3800072 to your computer and use it in GitHub Desktop.
Gurgeh's Zsh prompt
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
echo '%(!.!.➜)'
}
function parse_hg_dirty {
if [[ -n $(hg status -mard . 2> /dev/null) ]]; then
echo "$ZSH_THEME_HG_PROMPT_DIRTY"
fi
}
function get_RAM {
free -m | awk '{if (NR==3) print $4}' | xargs -i echo 'scale=1;{}/1000' | bc
}
function get_nr_jobs() {
jobs | wc -l
}
function get_nr_CPUs() {
grep -c "^processor" /proc/cpuinfo
}
function get_load() {
uptime | awk '{print $11}' | tr ',' ' '
}
PROMPT='%{$fg_bold[green]%}%n@%m %{$fg[cyan]%}%2c %{$fg_bold[blue]%}$(git_prompt_info)$(parse_hg_dirty)%{$fg_bold[blue]%} %{$fg_bold[red]%}$(prompt_char) % %{$reset_color%}'
RPROMPT='%{$fg_bold[red]%}[$(get_nr_jobs), $(get_RAM)G, $(get_load)($(get_nr_CPUs))] %{$fg_bold[green]%}%*%{$reset_color%}'
ZSH_THEME_HG_PROMPT_PREFIX="hg:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@salfedev
Copy link

salfedev commented Nov 1, 2019

Where do I place this? .zshrc ?

@gurgeh
Copy link
Author

gurgeh commented Nov 1, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment