|
|
|
#
|
|
|
|
# Executes commands at the start of an interactive session.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
|
|
|
# Source Prezto.
|
|
|
|
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
|
|
|
|
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
|
|
|
|
fi
|
|
|
|
|
|
|
|
export PATH=~/.dotfiles/bin:$PATH
|
|
|
|
export EDITOR=nvim
|
|
|
|
export VISUAL=nvim
|
|
|
|
export RPROMPT=
|
|
|
|
|
|
|
|
if command -v direnv &> /dev/null; then
|
|
|
|
eval "$(direnv hook zsh)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
export NIX_PATH=${NIX_PATH:+$NIX_PATH:}$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels
|
|
|
|
|
|
|
|
zstyle :prompt:pure:prompt:success color green
|
|
|
|
|
|
|
|
unsetopt correct # Don't autocorrect
|
|
|
|
unsetopt flowcontrol # So ^S and ^Q can be used
|
|
|
|
setopt no_nomatch # Pass bad matches on
|
|
|
|
setopt no_share_history
|
|
|
|
setopt prompt_subst interactive_comments # Starship: https://github.com/sorin-ionescu/prezto/issues/1887#issuecomment-1040761561
|
|
|
|
|
|
|
|
bindkey "\ep" history-beginning-search-backward
|
|
|
|
bindkey "\en" history-beginning-search-forward
|
|
|
|
|
|
|
|
alias be='bundle exec'
|
|
|
|
alias tat='tmux new-session -As `basename $PWD | ruby -e "puts ARGF.read.strip.downcase.gsub(/[^\w]+/, ?-)"`'
|
|
|
|
alias plz=sudo
|
|
|
|
alias emacs="emacs --no-window"
|
|
|
|
alias tmux="direnv exec / tmux"
|
|
|
|
|
|
|
|
function eject { command hdiutil eject `df | grep Volumes | grep -i "$@" | ruby -ne 'puts $_[/^[^ ]*/]'`; }
|
|
|
|
|
|
|
|
# allow for pasting commands from the interwebs with a preceding $ prompt
|
|
|
|
function \$() { "$@" }
|
|
|
|
|
|
|
|
if [ -e $(brew --prefix z.lua)/share/z.lua/z.lua ]; then
|
|
|
|
eval "$(lua $(brew --prefix z.lua)/share/z.lua/z.lua --init zsh enhanced once echo fzf)"
|
|
|
|
|
|
|
|
alias fz="z -I"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $commands[eza] ]; then
|
|
|
|
alias ls=eza
|
|
|
|
export EZA_COLORS="di=34"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $commands[bat] ]; then
|
|
|
|
export BAT_THEME="ashes"
|
|
|
|
fi
|
|
|
|
|
|
|
|
### homebrew
|
|
|
|
|
|
|
|
eval "$(brew shellenv)"
|
|
|
|
|
|
|
|
### fzf
|
|
|
|
|
|
|
|
if [ $commands[fzf] ]; then
|
|
|
|
[[ $- == *i* ]] && source "/opt/homebrew/opt/fzf/shell/completion.zsh" 2> /dev/null
|
|
|
|
|
|
|
|
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
|
|
|
|
export FZF_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix --hidden --follow --exclude .git"
|
|
|
|
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
|
|
|
export FZF_ALT_C_COMMAND="fd --type d --strip-cwd-prefix --hidden --follow --exclude .git"
|
|
|
|
# alias fzf='fzf-tmux -p'
|
|
|
|
|
|
|
|
# https://github.com/junegunn/fzf/issues/164#issuecomment-581837757
|
|
|
|
bindkey "ç" fzf-cd-widget
|
|
|
|
|
|
|
|
source ~/.dotfiles/src/fzf-git.sh/fzf-git.sh
|
|
|
|
|
|
|
|
# ^gb is eaten by tmux
|
|
|
|
eval "bindkey '^gg' fzf-git-branches-widget"
|
|
|
|
|
|
|
|
# I don't know why ^gl doesn't work - is it because ^l is eaten by tmux?
|
|
|
|
eval "bindkey '^gr' fzf-git-lreflogs-widget"
|
|
|
|
|
|
|
|
# https://github.com/skywind3000/z.lua/wiki/Effective-with-fzf#define-a-new-z--i
|
|
|
|
zlua_fzf() {
|
|
|
|
local dir
|
|
|
|
dir="$(z -l "$1" | fzf --nth 2.. -1 -0 --inline-info --no-sort +m --reverse --tac | sed -r 's/^[^[:space:]]+[[:space:]]+//')" && cd "${dir}" || return 1
|
|
|
|
}
|
|
|
|
alias j=zlua_fzf # override prezto's fasd integration
|
|
|
|
fi
|
|
|
|
|
|
|
|
### completions
|
|
|
|
|
|
|
|
if [ -x $(command -v jj) ]; then
|
|
|
|
source <(jj util completion --zsh)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e $(brew --prefix fzf)/shell/completion.zsh ]; then
|
|
|
|
source $(brew --prefix fzf)/shell/key-bindings.zsh
|
|
|
|
source $(brew --prefix fzf)/shell/completion.zsh
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -x "$(command -v kubectl)" ] && source <(kubectl completion zsh)
|
|
|
|
|
|
|
|
if [ -x "$(command -v terraform)" ]; then
|
|
|
|
autoload -U +X bashcompinit && bashcompinit
|
|
|
|
complete -o nospace -C /opt/homebrew/bin/terraform terraform
|
|
|
|
fi
|
|
|
|
|
|
|
|
# https://docs.brew.sh/Shell-Completion
|
|
|
|
if type brew &>/dev/null
|
|
|
|
then
|
|
|
|
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
|
|
|
|
|
|
|
|
autoload -Uz compinit
|
|
|
|
compinit
|
|
|
|
fi
|
|
|
|
|
|
|
|
### local overrides
|
|
|
|
|
|
|
|
[[ -s "$HOME/.zshrc.local" ]] && . "$HOME/.zshrc.local"
|