Created
October 10, 2017 19:33
-
-
Save woodrowbarlow/52b02ab27d0f8088891c3d6fb6a31edf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setopt +o nomatch | |
NEWLINE=$'\n' | |
source ~/.profile | |
show_git_branch () { | |
local desc=$(git symbolic-ref --short HEAD 2>/dev/null) | |
[[ -z "$desc" ]] && desc=$(git rev-parse --short HEAD 2>/dev/null) | |
[[ -z "$desc" ]] && return | |
echo -e " (\e[33m${desc}\e[0m)" | |
} | |
get_hash_color () { | |
local color=1 | |
local hashv=$(echo "$1" | md5sum | cut -d' ' -f1) | |
local hash1=${hashv:0:8} | |
local hash2=${hashv: -8} | |
hash1=$(printf "0x%s\n" $hash1) | |
hash1=$(printf "%d\n" $hash1) | |
hash2=$(printf "0x%s\n" $hash2) | |
hash2=$(printf "%d\n" $hash2) | |
(( hashv = $hash1 + $hash2 )) | |
(( color += $hashv % 9 )) | |
[[ $color > 6 ]] && (( color += 5 )) | |
echo -e "\e[2;38;5;${color}m" | |
} | |
export hostname_color=$(get_hash_color `hostname`) | |
export user_color=$(get_hash_color `id -un`) | |
autoload -U colors && colors | |
local ret_status="%(?::%{$fg_bold[red]%}✘%{$reset_color%}${NEWLINE})" | |
setopt PROMPT_SUBST | |
PROMPT='${ret_status} | |
%{$hostname_color%}%n@%M%{$reset_color%}: %{$fg[green]%}%5~%{$reset_color%}$(show_git_branch) | |
%{$fg[yellow]%}[%D{%b %d %T}]%{$reset_color%} %{$fg_bold[blue]%}➜%{$reset_color%} ' | |
TMOUT=1 | |
TRAPALRM() { | |
zle reset-prompt | |
} | |
case $TERM in | |
xterm*) | |
precmd () { print -Pn "\e]0;%n@%M: %~\a" } | |
;; | |
esac | |
[[ -f ~/.zsh_aliases ]] && source ~/.zsh_aliases | |
echo -e "\e[33m" | |
fortune | |
echo -e "\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment