# Lines configured by zsh-newuser-install HISTFILE=~/.histfile HISTSIZE=1000 SAVEHIST=1000 setopt autocd notify unsetopt beep bindkey -v # End of lines configured by zsh-newuser-install # SSH completion zstyle ':completion:*:(ssh|scp|ftp|sftp|rsync):*' hosts $hosts # The following lines were added by compinstall zstyle :compinstall filename '/home/d_mcknight/.zshrc' autoload -Uz compinit compinit # End of lines added by compinstall # Source common envvars [ -f ~/.profile ] && source ~/.profile # Prompt function precmd { # Check previous command output and notify if [[ $? != 0 && $? != 130 ]];then echo -e "⚠️\a" else echo -e "\a" fi if [ "$EUID" -eq 0 ];then chrome_color="{red}" else chrome_color="{magenta}" fi # Static prefix prefix="%F$chrome_color┌──[%F{cyan}%n%F$chrome_color@%F{cyan}%m%F$chrome_color]-" # Calculate extra path if [[ ${debian_chroot} ]]; then path_extra="(%F{red}${debian_chroot}%F$chrome_color)-" elif [[ ${VIRTUAL_ENV} ]]; then rel_venv=$(realpath $VIRTUAL_ENV --relative-to $PWD --relative-base /home) path_extra="[%F{blue}${rel_venv}%F$chrome_color]-" else; path_extra="" fi # Static suffix suffix="(%F{blue}%~%F${chrome_color})"$'\n'"└%F{cyan}%#%F{white} " PROMPT=$prefix$path_extra$suffix PS2="%F$chrome_color└%F{cyan}>%F{white} " } # Aliases alias .=source alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' alias k9=k9s alias rsync="rsync -e 'ssh -o RemoteCommand=none'" alias sudosu="sudo ZDOTDIR=$(dirname ${0:a}) zsh" alias ll='ls -alFh' alias ls="ls --color=auto" alias lsl="ls --color=auto -lah" alias ssh=ssh # Use tmux for local unelevated shells if [ -z "${SUDO_USER}" ] && [ -z "${SSH_CONNECTION}" ] && [ -z "${TERM_PROGRAM}" ]; then tmux new -A -s local_tmux fi # Define a function to use autossh with a custom bashrc function assh() { remote_file=$(mktemp) if $(ssh "$@" "cat > ${remote_file}" < ~/.bashrc > /dev/null 2>&1); then # Successfully copied bashrc to the remote. Source it upon ssh autossh -t "$@" "bash --rcfile ${remote_file}; rm ${remote_file}" else # SSH Config specifies a RemoteCommand; connect normally autossh "$@" fi } # Use ssh completion for autossh compdef autossh=ssh compdef assh=ssh # Custom dircolors [ -f ~/.dircolors ] && eval "$(dircolors ~/.dircolors)" # Kubernetes Completion which kubectl 1> /dev/null && source <(kubectl completion zsh) which helm 1> /dev/null && source <(helm completion zsh) # doctl completion which doctl 1> /dev/null && source <(doctl completion zsh) # Start in the home directory cd ~ # Ensure zinit is installed ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" [ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)" [ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" source "${ZINIT_HOME}/zinit.zsh" # Load zinit plugins zinit snippet OMZP::extract zinit snippet OMZP::colored-man-pages zinit snippet OMZP::encode64 zinit snippet OMZP::gh zinit snippet OMZP::pip zinit snippet OMZP::sudo zinit light zsh-users/zsh-autosuggestions zinit light zsh-users/zsh-syntax-highlighting # Key bindings config KEYTIMEOUT=5 # ^[ for esc; ^I for tab bindkey '^[[Z' autosuggest-accept ## Explicitly exit ok #echo "" > /dev/null