You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.1 KiB

#
# Executes commands at the start of an interactive session.
#
11 months ago
[ -z "$ZPROF" ] || zmodload zsh/zprof
# 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
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
1 year ago
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
3 years ago
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
2 years ago
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]+/, ?-)"`'
7 years ago
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 $_[/^[^ ]*/]'`; }
1 year ago
# allow for pasting commands from the interwebs with a preceding $ prompt
function \$() { "$@" }
1 year ago
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"
7 years ago
fi
7 years ago
1 year ago
if [ $commands[eza] ]; then
alias ls=eza
export EZA_COLORS="di=34"
fi
1 year ago
if [ $commands[bat] ]; then
export BAT_THEME="ashes"
2 years ago
fi
1 year ago
### homebrew
eval "$(brew shellenv)"
### fzf
if [ $commands[fzf] ]; then
[[ $- == *i* ]] && source "/opt/homebrew/opt/fzf/shell/completion.zsh" 2> /dev/null
2 years ago
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
2 years ago
export FZF_DEFAULT_COMMAND="fd --type f --strip-cwd-prefix --hidden --follow --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
2 years ago
export FZF_ALT_C_COMMAND="fd --type d --strip-cwd-prefix --hidden --follow --exclude .git"
2 years ago
# alias fzf='fzf-tmux -p'
# https://github.com/junegunn/fzf/issues/164#issuecomment-581837757
bindkey "ç" fzf-cd-widget
2 years ago
source ~/.dotfiles/src/fzf-git.sh/fzf-git.sh
2 years ago
# ^gb is eaten by tmux
eval "bindkey '^gg' fzf-git-branches-widget"
1 year ago
# I don't know why ^gl doesn't work - is it because ^l is eaten by tmux?
eval "bindkey '^gr' fzf-git-lreflogs-widget"
2 years ago
# 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
7 years ago
fi
7 years ago
1 year ago
### completions
1 year ago
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
1 year ago
[ -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
1 year ago
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
# Added by OrbStack: command-line tools and integration
source ~/.orbstack/shell/init.zsh 2>/dev/null || :
1 year ago
### local overrides
2 years ago
7 years ago
[[ -s "$HOME/.zshrc.local" ]] && . "$HOME/.zshrc.local"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
11 months ago
[ -z "$ZPROF" ] || zprof