dotfiles/zsh/.zshrc
2023-12-01 17:52:23 +00:00

95 lines
2.7 KiB
Bash

alias ls='ls --color=auto'
alias mailx='/usr/local/bin/mailx'
alias grep='grep --color'
alias vim='nvim'
alias vi='nvim'
alias w3='w3m -T text/html'
# allow for # to be interpreted as a comment on the command line
setopt interactivecomments
# 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
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
if [ -n "$SSH_AUTH_SOCK" ]; then
if [ "$SSH_AUTH_SOCK" != ~/.ssh/ssh_auth_sock ]; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
fi
fi
if [ -e /usr/bin/keychain ]; then
eval $(/usr/bin/keychain --eval --agents ssh -Q --quiet id_ed25519)
fi
# direnv setup
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
h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
fi
if [[ -r ~/.ssh/known_hosts ]]; then
h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
fi
if [[ $#h -gt 0 ]]; then
zstyle ':completion:*:(ssh|scp|slogin|sftp):*' hosts $h
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