Skip to content

Instantly share code, notes, and snippets.

@evenme
Last active April 27, 2021 17:39
Show Gist options
  • Save evenme/5582f327a128cede291b564bbcec45fc to your computer and use it in GitHub Desktop.
Save evenme/5582f327a128cede291b564bbcec45fc to your computer and use it in GitHub Desktop.
export DOTFILES="$HOME/dotfiles"
export ZSH="$DOTFILES/zsh"
export PATH="/usr/local/opt/helm@2/bin:$HOME/.rvm/bin:/usr/local/bin:/usr/local/sbin:$PATH"
export EDITOR="/usr/local/bin/mvim -v"
export PAGER='less'
export LESS='-giR'
export READNULLCMD='bat'
export MANPAGER="sh -c 'col -bpx | bat -l man -p'"
export BAT_PAGER="less $LESS"
# Color grep
alias grep='grep --color=always'
# Colors for ls and completions
# znap eval dircolors 'gdircolors -b'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
alias ls='ls -AFH'
# aliases
alias vim="mvim -v"
alias zshreload="source $HOME/.zshrc"
# history
HISTFILE=~/.zsh_history
HISTSIZE=100000
HISTFILESIZE=999999
HISTIGNORE=""
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
## workaround for handling TERM variable in multiple tmux sessions properly from http://sourceforge.net/p/tmux/mailman/message/32751663/ by Nicholas Marriott
# if [[ -n ${TMUX} && -n ${commands[tmux]} ]];then
# case $(tmux showenv TERM 2>/dev/null) in
# *256color) ;&
# TERM=fbterm)
# TERM=screen-256color ;;
# *)
# TERM=screen
# esac
# fi
# Homebrew token
source "$DOTFILES/homebrew_token"
# Load antigen library
source "$DOTFILES/zsh/antigen/antigen.zsh"
# zsh tmux settings
ZSH_TMUX_AUTOSTART=false
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
antigen bundles <<EOBUNDLES
arialdomartini/oh-my-git
aws
colored-man-pages
command-not-found
common-aliases
cp
docker
docker-compose
extract
fzf
git
git-extras
gitignore
helm
kubectl
kubectx
kubens
nmap
osx
safe-paste
spotify
ssh-agent
terraform
thewtex/tmux-mem-cpu-load
tmux
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-syntax-highlighting
EOBUNDLES
THEME=romkatv/powerlevel10k
antigen list | grep $THEME; if [ $? -ne 0 ]; then antigen theme $THEME; fi
antigen apply
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f $DOTFILES/zsh/p10k.zsh ]] || source $DOTFILES/zsh/p10k.zsh
POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
# AWS autocompletion
# autoload bashcompinit && bashcompinit
# source /usr/local/share/zsh/site-functions
# complete -C '/usr/local/bin/aws_completer' aws
# Kubernetes autocompletion
# source <(kubectl completion zsh)
alias kctx="kubectx"
alias kns="kubens"
alias k=kubectl
complete -F __start_kubectl k
#source "/usr/local/opt/kube-ps1/share/kube-ps1.sh"
#PS1='$(kube_ps1)'$PS1
# keybinds
bindkey "\033[1~" beginning-of-line
bindkey "\033[4~" end-of-line
bindkey '^[[1;9C' forward-word
bindkey '^[[1;9D' backward-word
bindkey '^ ' autosuggest-accept
# FZF
# [ -f $DOTFILES/zsh/fzf.zsh ] && source $DOTFILES/zsh/fzf.zsh
# source $DOTFILES/zsh/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh
# # only aws command completion
# zstyle ':completion:*:*:aws' fzf-search-display true
# # or for everything
# # zstyle ':completion:*' fzf-search-display true
# zoxide
eval "$(zoxide init zsh)"
# Make short hostname only if its not an IP address
__tm_get_hostname(){
local HOST="$(echo $* | rev | cut -d ' ' -f 1 | rev)"
if echo $HOST | grep -E "^([0-9]+\.){3}[0-9]+" -q; then
echo $HOST
else
echo $HOST| cut -d . -f 1
fi
}
__tm_get_current_window(){
tmux list-windows| awk -F : '/\(active\)$/{print $1}'
}
# Rename window according to __tm_get_hostname and then restore it after the command
__tm_command() {
if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=| cut -d : -f 1)" = "tmux" ]; then
__tm_window=$(__tm_get_current_window)
# Use current window to change back the setting. If not it will be applied to the active window
trap "tmux set-window-option -t $__tm_window automatic-rename on 1>/dev/null" EXIT
tmux rename-window "$(__tm_get_hostname $*)"
fi
command "$@"
}
ssh() {
__tm_command ssh -A "$@"
}
ec2ssh() {
__tm_command ec2ssh -A "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment