Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solarized Prompt Theme, MacPorts, and Zsh Version #186

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
min_zsh_version='4.3.10'
if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
print "omz: old shell detected, minimum required: $min_zsh_version" >&2
return 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to act as a warning, not fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I login to alot of el5 boxes with older zsh....made it return as they throw errors to do with add-zsh-hook....will look to see if i can get it working on el5s version of zsh

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that a partially working OMZ is probably better than no OMZ. Being pestered with errors is not good though. I'll take another look.

fi
unset min_zsh_version

Expand Down
8 changes: 8 additions & 0 deletions modules/macports/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# Matt Cable <[email protected]>
#

if [[ "$OSTYPE" != darwin* ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll fix this and the paths. You don't need to open another pull request.

return 1
fi

# Aliases
alias pc="sudo port clean --all installed"
alias pi="sudo port install $1"
Expand All @@ -13,3 +17,7 @@ alias puni="sudo port uninstall inactive"
alias puo="sudo port upgrade outdated"
alias pup="psu && puo"

path=(
/opt/local/{bin,sbin}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacPorts, much like Homebrew, can be installed in many different places. It's probably better to set the path manually in zshenv.

$path
)
156 changes: 156 additions & 0 deletions modules/prompt/functions/prompt_solarized_setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#
# A theme based on Steve Losh's prompt with VCS_INFO integration
# Tweaked with solarized colors for 256/16 color modes
#
# Authors:
# Steve Losh <[email protected]>
# Bart Trojanowski <[email protected]>
# Brian Carper <[email protected]>
# solarized <[email protected]>
# Sorin Ionescu <[email protected]>
# Ben O'Hara <[email protected]>
#
# Activate in .zshrc:
#
# zstyle ':omz:module:prompt' theme 'solarized'
#
# and settings:
#
# zstyle ':omz:module:prompt:solarized' 256colors 'yes'
# zstyle ':omz:module:prompt:solarized' dark 'yes'
#
# custom hostname colours
#
# zstyle ':omz:module:prompt:solarized' hostname 'red'
# zstyle ':omz:module:prompt:solarized' hostname2 'blue'
#
#

function virtualenv_info {
if [[ -n "$VIRTUAL_ENV" ]]; then
print "(${VIRTUAL_ENV:t}) "
fi
}

function prompt_solarized_precmd {
if [[ -n "$__PROMPT_solarized_VCS_UPDATE" ]] ; then
# Check for untracked files or updated submodules since vcs_info doesn't.
if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
__PROMPT_solarized_VCS_UPDATE=1
fmt_branch=" ($prompt_orange%b%f%u%c$prompt_red●%f)"
else
fmt_branch=" ($prompt_orange%b%f%u%c)"
fi
zstyle ':vcs_info:*:prompt:*' formats "${fmt_branch}"

vcs_info 'prompt'
__PROMPT_solarized_VCS_UPDATE=''
fi
}

function prompt_solarized_preexec {
case "$(history $HISTCMD)" in
(*git*)
__PROMPT_solarized_VCS_UPDATE=1
;;
(*svn*)
__PROMPT_solarized_VCS_UPDATE=1
;;
esac
}

function prompt_solarized_chpwd {
__PROMPT_solarized_VCS_UPDATE=1
}

function prompt_solarized_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)

autoload -Uz add-zsh-hook
autoload -Uz vcs_info

add-zsh-hook precmd prompt_solarized_precmd
add-zsh-hook preexec prompt_solarized_preexec
add-zsh-hook chpwd prompt_solarized_chpwd

__PROMPT_solarized_VCS_UPDATE=1

zstyle -b ':omz:module:prompt:solarized' 256colors '_prompt_256colors'
if is-true "${_prompt_256colors}"; then
prompt_base03="%F{234}" # brblack base03
prompt_base02="%F{235}" # black base02
prompt_base01="%F{240}" # brgreen base01
prompt_base00="%F{241}" # bryellow base00
prompt_base0="%F{244}" # brblue base0
prompt_base1="%F{245}" # brcyan base1
prompt_base2="%F{254}" # white base2
prompt_base3="%F{230}" # brwhite base3
prompt_yellow="%F{136}" # yellow yellow
prompt_orange="%F{166}" # brred orange
prompt_red="%F{160}" # red red
prompt_magenta="%F{125}" # magenta magenta
prompt_violet="%F{61}" # brmagenta violet
prompt_blue="%F{33}" # blue blue
prompt_cyan="%F{37}" # cyan cyan
prompt_green="%F{64}" # green green
else
prompt_base03="%F{black}%FX{bold}" # brblack base03
prompt_base02="%F{black}" # black base02
prompt_base01="%F{green}%FX{bold}" # brgreen base01
prompt_base00="%F{yellow}%FX{bold}" # bryellow base00
prompt_base0="%F{blue}%FX{bold}" # brblue base0
prompt_base1="%F{cyan}%FX{bold}" # brcyan base1
prompt_base2="%F{white}" # white base2
prompt_base3="%F{white}%FX{bold}" # brwhite base3
prompt_yellow="%F{yellow}" # yellow yellow
prompt_orange="%F{red}%FX{bold}" # brred orange
prompt_red="%F{red}" # red red
prompt_magenta="%F{magenta}" # magenta magenta
prompt_violet="%F{magenta}%FX{bold}" # brmagenta violet
prompt_blue="%F{blue}" # blue blue
prompt_cyan="%F{cyan}" # cyan cyan
prompt_green="%F{green}" # green green
fi
# Enable VCS systems you use.
zstyle ':vcs_info:*' enable git hg svn cvs

# check-for-changes can be really slow.
# You should disable it if you work with large repositories.
zstyle ':vcs_info:*:prompt:*' check-for-changes true

# Formats:
# %b - branchname
# %u - unstagedstr (see below)
# %c - stagedstr (see below)
# %a - action (e.g. rebase-i)
# %R - repository path
# %S - path in the repository
local fmt_branch=" ($prompt_orange%b%f%u%c)"
local fmt_action=" ($prompt_blue%a%f)"
local fmt_unstaged="$prompt_red+%f"
local fmt_staged="$prompt_green+%f"

zstyle ':vcs_info:*:prompt:*' unstagedstr "${fmt_unstaged}"
zstyle ':vcs_info:*:prompt:*' stagedstr "${fmt_staged}"
zstyle ':vcs_info:*:prompt:*' actionformats "${fmt_branch} ${fmt_action}"
zstyle ':vcs_info:*:prompt:*' formats "${fmt_branch}"
zstyle ':vcs_info:*:prompt:*' nvcsformats ""

prompt_host=$prompt_green
zstyle -a ':omz:module:prompt:solarized' $HOST '_prompt_host'
if [ ! -z $_prompt_host ]; then
prompt_host=$"prompt_$_prompt_host"
fi
zstyle -b ':omz:module:prompt:solarized' dark '_prompt_dark'
if is-true "${_prompt_dark}"; then
PROMPT="%(!.$prompt_red.$prompt_host)%n%f$prompt_base1 at $prompt_host%m%f$prompt_base1 in $prompt_base01%~%f"'${vcs_info_msg_0_}'"
"'$(virtualenv_info)'"$prompt_base1 %# $prompt_base0"
else
PROMPT="%(!.$prompt_red.$prompt_host)%n%f$prompt_base01 at $prompt_host%m%f$prompt_base01 in $prompt_base1%~%f"'${vcs_info_msg_0_}'"
"'$(virtualenv_info)'"$prompt_base01 %# $prompt_base00"
fi
}

prompt_solarized_setup "$@"