dotfiles/zsh/.zshrc
2024-06-01 23:47:23 +00:00

112 lines
3.1 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'
path+=(~/bin)
path+=(~/.local/bin)
path+=($GOPATH/bin)
export PATH
# 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
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" != $HOME/.ssh/ssh_auth_sock ]; then
# ln -sf $SSH_AUTH_SOCK $HOME/.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)"
# setup CFA environment
if [ -e $HOME/cfa-work/.zshrc ]; then
. $HOME/cfa-work/.zshrc
fi
# setup okta-aws-cli env
# export $(xargs < $HOME/.okta/.env)
# setup aws-cli env
export $(xargs < $HOME/.aws/.env)
# setup gh env
export $(xargs < $HOME/.config/git/.env)
autoload bashcompinit && bashcompinit
autoload -Uz compinit
compinit
# kubectl
[[ $commands[kubectl] ]] && source <(kubectl completion zsh)
# Highlight the current autocomplete option
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# 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'
complete -C '/usr/bin/aws_completer' aws
#zstyle ':completion:*' completer _complete _ignored
#zstyle :compinstall filename '~/.zshrc'
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /home/cli/.local/bin/terraform terraform