diff --git a/zsh/.zshrc b/zsh/.zshrc index dc5e926..c9120c7 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,5 +1,4 @@ alias ls='ls --color=auto' -alias mailx='/usr/local/bin/mailx' alias grep='grep --color' alias vim='nvim' alias vi='nvim' @@ -8,23 +7,52 @@ alias w3='w3m -T text/html' # allow for # to be interpreted as a comment on the command line setopt interactivecomments -PROMPT="%B%m:%~> %b" - # cd tricks alias -- -='cd -' setopt auto_cd # there is no binary by that name in your $PATH, your shell will cd into it that directory +# use vi-style keymap bindkey -v if [ "${TERM}" = "xterm" ]; then TERM=xterm-256color fi -case $TERM in - xterm*|st-256color|rxvt-unicode-256color) - print -Pn "\e]0;%m\a" - ;; -esac +# +# Prompt setup +# + +# populate colors arrays +autoload -U colors && colors + +# git branch prompt +autoload -Uz vcs_info +setopt prompt_subst + +precmd_vcs_info() { vcs_info } +precmd_functions+=( precmd_vcs_info ) + +# %% escapes '%' +# %S == "standout" => reverses fg/bg +# Surround color codes with '%{' and '%}' +# %r == repo name +# %b == branch name +# %S == relative directory +zstyle ':vcs_info:git*' formats '%%S%r%%s:%{$fg[red]%}%b%{$reset_color%} %S' +zstyle ':vcs_info:git*' actionformats '%%S%r%%s:%{$fg[red]%}%b:%a%{$reset_color%} %S' + +function set_prompt() { + if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + PROMPT="%B${vcs_info_msg_0_}> %b" + else + PROMPT="%B%m:%~> %b" + fi +} +precmd_functions+=( set_prompt ) + +# +# Configure SSH auth sock +# if [ -n "$SSH_AUTH_SOCK" ]; then if [ "$SSH_AUTH_SOCK" != ~/.ssh/ssh_auth_sock ]; then @@ -33,6 +61,7 @@ if [ -n "$SSH_AUTH_SOCK" ]; then fi fi +# setup SSH keys if [ -e /usr/bin/keychain ]; then eval $(/usr/bin/keychain --eval --agents ssh -Q --quiet id_ed25519) fi @@ -43,33 +72,6 @@ whence -p direnv &>/dev/null && eval "$(direnv hook zsh)" # Highlight the current autocomplete option zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" -# asdf setup -if [ -e $HOME/.asdf/asdf.sh ]; then - . "$HOME/.asdf/asdf.sh" - fpath=(${ASDF_DIR}/completions $fpath) -fi - -# git branch prompt -setopt prompt_subst -autoload -Uz vcs_info -zstyle ':vcs_info:*' actionformats \ - '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' -zstyle ':vcs_info:*' formats \ - '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' -zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' - -zstyle ':vcs_info:*' enable git cvs svn - - -# Better SSH/Rsync/SCP Autocomplete -#zstyle ':completion:*:(scp|rsync):*' tag-order ' hosts:-ipaddr:ip\ address hosts:-host:host files' -#zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost -#zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*' -# -# Allow for autocomplete to be case insensitive -#zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' \ -# '+l:|?=** r:|?=**' - # command line completion for ssh h=() if [[ -r ~/.ssh/config ]]; then @@ -85,12 +87,3 @@ fi zstyle :compinstall filename '~/.zshrc' autoload -Uz compinit compinit - -# The following lines were added by compinstall - -#zstyle ':completion:*' completer _complete _ignored -#zstyle :compinstall filename '~/.zshrc' -# -#autoload -Uz compinit -#compinit -# End of lines added by compinstall