130 lines
2.8 KiB
Bash
130 lines
2.8 KiB
Bash
alias ls='ls --color=auto'
|
|
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
|
|
|
|
# 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
|
|
|
|
#
|
|
# 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 '%r (%b):%S'
|
|
zstyle ':vcs_info:git*' actionformats '%%S%r%%s:%{$fg[red]%}%b:%a%{$reset_color%} %S'
|
|
|
|
function set_prompt() {
|
|
|
|
if [[ -n "$AWS_ENVIRONMENT" ]]; then
|
|
aws_prompt="
|
|
%S%B$AWS_ENVIRONMENT%b%s
|
|
"
|
|
else
|
|
aws_prompt=""
|
|
fi
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
PROMPT=$aws_prompt"%B${vcs_info_msg_0_}> %b"
|
|
else
|
|
PROMPT=$aws_prompt"%B%m:%~> %b"
|
|
fi
|
|
}
|
|
precmd_functions+=( set_prompt )
|
|
|
|
#
|
|
# Configure SSH auth sock
|
|
#
|
|
|
|
#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
|
|
|
|
# setup SSH keys
|
|
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
|
|
|
|
for env in $HOME/.okta/.env $HOME/.aws/.env $HOME/config/git/.env; do
|
|
if [ -r $env ]; then
|
|
export $(xargs < $env)
|
|
fi
|
|
done
|
|
|
|
# command line completion
|
|
autoload -U +X bashcompinit && bashcompinit
|
|
autoload -Uz compinit && compinit
|
|
|
|
# kubectl
|
|
[[ $commands[kubectl] ]] && source <(kubectl completion zsh)
|
|
|
|
# AWS CLI completion
|
|
if command -v aws_completer > /dev/null; then
|
|
complete -C aws_completer aws
|
|
fi
|
|
|
|
|
|
# Highlight the current autocomplete option
|
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
|
|
|
# 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'
|
|
|
|
#zstyle ':completion:*' completer _complete _ignored
|
|
#zstyle :compinstall filename '~/.zshrc'
|
|
|
|
#compinit
|