#!/bin/zsh [ ! -f $XDG_DATA_HOME/zsh/history ] && mkdir -p $XDG_DATA_HOME/zsh && touch $XDG_DATA_HOME/zsh/history fpath=($XDG_CONFIG_HOME/zsh/completions $fpath) setopt hist_ignore_all_dups hist_reduce_blanks hist_verify bang_hist interactive_comments autocd noflowcontrol longlistjobs nonomatch notify hash_list_all appendhistory sharehistory histignorespace prompt_subst autoload -Uz colors && colors autoload -Uz edit-command-line && zle -N edit-command-line autoload -Uz add-zsh-hook autoload -Uz compinit zstyle ':completion:*:git-checkout:*' sort false zstyle ':completion:*:descriptions' format '[%d]' zstyle ':completion:*' list-colors "${(s/:/)LS_COLORS}" zstyle ':completion:*' menu no zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup zstyle ':fzf-tab:*' switch-group '<' '>' zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls $realpath' zmodload zsh/complist compinit _comp_options+=(globdots) zle_highlight+=(paste:none) # Set the titlestring add-zsh-hook preexec write_title_cmd add-zsh-hook precmd write_title_wd add-zsh-hook preexec reset_beam export HISTSIZE=10000000 export SAVEHIST=10000000 export HISTFILE="$XDG_DATA_HOME/zsh/history" export KEYTIMEOUT=1 # Virtualenvwrapper Setup source "$(which virtualenvwrapper_lazy.sh)" type workon >/dev/null 2>&1 [ -z "$WORKON_HOME" ] && { echo "$WORKON_HOME unset!" return 1 } workon_cwd() { local PROJECT_ROOT="${PWD}" while [ "$PROJECT_ROOT" != "/" ] && [ ! -e "$PROJECT_ROOT/.venv" ] && [ ! -d "$PROJECT_ROOT/.git" ]; do local PROJECT_ROOT="$(dirname "$PROJECT_ROOT")" done if [ -r "$PROJECT_ROOT/.venv" ]; then local ENV_NAME="$(cat $PROJECT_ROOT/.venv)" # else # ENV_NAME="$(basename "$PROJECT_ROOT")" fi [ -n "$CD_VIRTUAL_ENV" ] && [ "$ENV_NAME" != "$CD_VIRTUAL_ENV" ] && { [ -n "$VIRTUAL_ENV" ] && deactivate unset CD_VIRTUAL_ENV } [ -n "$ENV_NAME" ] && [ ! "$(realpath "$VIRTUAL_ENV" 2>/dev/null)" = "$(realpath "$WORKON_HOME/$ENV_NAME")" ] && { if [ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]; then workon -n "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" elif [ -e "$ENV_NAME/bin/activate" ]; then source "$ENV_NAME/bin/activate" && export CD_VIRTUAL_ENV="$ENV_NAME" else local ENV_NAME="" fi } [ -z "$ENV_NAME" ] && [ -n "$CD_VIRTUAL_ENV" ] && [ -n "$VIRTUAL_ENV" ] && { deactivate && unset CD_VIRTUAL_ENV } } autoload -U add-zsh-hook add-zsh-hook chpwd workon_cwd [ "$PWD" != ~ ] && workon_cwd