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.

82 lines
2.1 KiB

#
# 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 EDITOR=vim
export VISUAL=vim
export RPROMPT=
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
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 ls=exa
alias emacs="emacs --no-window"
alias tmux="direnv exec / tmux"
function eject { command hdiutil eject `df | grep Volumes | grep -i "$@" | ruby -ne 'puts $_[/^[^ ]*/]'`; }
if [ $commands[chruby] ]; then
chruby ruby
fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
if [ -e /usr/local/opt/fzf/shell/completion.zsh ]; then
source /usr/local/opt/fzf/shell/key-bindings.zsh
source /usr/local/opt/fzf/shell/completion.zsh
fi
if [ $commands[fzf] ]; then
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
export FZF_DEFAULT_COMMAND="rg --files"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="find . -type d"
# alias fzf=fzf-tmux
z() {
[ $# -gt 0 ] && fasd_cd -d "$*" && return
local dir
dir="$(fasd -Rdl "$1" | fzf -1 -0 --no-sort +m)" && cd "${dir}" || return 1
}
# CTRL-G
__fgit() {
local cmd="git status --porcelain | awk '{ print \$2 }'"
setopt localoptions pipefail no_aliases 2> /dev/null
local item
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS" $(__fzfcmd) -m "$@" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}
fzf-git-widget() {
LBUFFER="${LBUFFER}$(__fgit)"
local ret=$?
zle reset-prompt
return $ret
}
zle -N fzf-git-widget
bindkey '^G' fzf-git-widget
fi
[[ -s "$HOME/.zshrc.local" ]] && . "$HOME/.zshrc.local"