Mercurial > dotfiles
view .shell.d/99.prompt.zsh @ 377:117e3c11d953
zprofile: introduce zprofile use
El Capitan (OS X 10.11) introduces a system-level /etc/zprofile which
uses a path_helper thing to mangle $PATH. Unfortunately, the way
path_helper works, it forces /usr/local/bin and /usr/bin to the
*start* of the PATH variable, which means that any PATH mutations I
want have to run after /etc/zprofile calls path_helper. As such, move
my path insertions into .zprofile{,-machine} rather than
.zshenv{,-machine} so that I can still ensure my path entries are at
the start of PATH rather than the end. This works because:
> Commands are then read from $ZDOTDIR/.zshenv. If the shell is a
> login shell, commands are read from /etc/zprofile and then
> $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands
> are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the
> shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
This means that non-login shells no longer pick up my custom PATH
entries, but as I only use OS X as a desktop OS that seems like a
workable tradeoff for now.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 31 Jan 2016 20:46:29 -0500 |
parents | 02b635053e8f |
children | 0ceb8554801e |
line wrap: on
line source
# Magic prompt with colors # username in blue if not root # username in red if root - time in pink w/ # DANGER replacing the date # failed jobs print exit status in the RPS1 with yellow text setopt prompt_subst preexec () { currJob="`echo $3 | cut -d ' ' -f 1 | head -n 1`" if [[ "$TERM" == "screen" ]]; then hostUser="%10<...<%~%<<" print -Pn "\ek[$hostUser $currJob]\e\\" else if [[ "$FANCYTYPE" == "YES" ]]; then hostUser="%n@%m: %2~" print -Pn "\e]0;$hostUser [$currJob]\a" fi fi } function right_side_prompt() { branch=`vcs_current_branch` if [ $? = 0 ] ; then echo -n $branch else date '+%D %H:%M' fi } function precmd () { rps_branch=`right_side_prompt` } if [ "x`whoami`" = "xroot" ] ; then PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' if [[ "$TERM" == "screen" ]] ; then PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# ' fi RPS1=$'%{\e[1;35m%}[DANGER %t]%{\e[0m%}%(?..%{\e[1;33m%} %?%{\e[1;0m%})' else PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# ' if [[ "$TERM" == "screen" ]]; then PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# ' fi RPS1=$'[$rps_branch]%(?..%{\e[1;33m%} %?%{\e[0m%})' fi export FANCYTYPE="NO" for ok in rxvt rxvt-unicode xterm xterm-256color xterm-color screen ; do if [ "$TERM" = "$ok" ] ; then export FANCYTYPE="YES" fi done if [ $FANCYTYPE = "NO" ] ; then prompt='[%m:%3~] %n%# ' RPS1=$'[%W %t]' fi if [[ $TERM == "dumb" ]]; then # in emacs # for tramp to not hang, need the following. cf: # http://www.emacswiki.org/emacs/TrampMode unsetopt zle unsetopt prompt_cr unsetopt prompt_subst unfunction precmd unfunction preexec fi #nonfancy no-frills prompt - disabled (same as the "non-fancy" one above) #prompt='[%m:%3~] %n%# ' #RPS1=$'[%W %t]'