Last active
July 15, 2023 20:25
-
-
Save aanton/51958b1a9a207dc5c9edae042a490b55 to your computer and use it in GitHub Desktop.
fzf & fd combo for improving your ZSH shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fzf | |
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
export FZF_DEFAULT_OPTS="--multi --reverse --border --inline-info --preview '([ -e {} ] && (head -20 {} || tree -C {} | head -20 ) || (echo {})) 2> /dev/null' --preview-window=right:40%:wrap" | |
export FZF_CTRL_R_OPTS="--no-preview" | |
export FZF_CTRL_T_OPTS="--bind 'ctrl-x:execute(subl -a {})'" | |
# fzf bindigs | |
bindkey '^P' fzf-file-widget | |
# fzf + fd | |
export FZF_DEFAULT_COMMAND="(fd --hidden --exclude .git --follow || git ls-tree -r --name-only HEAD || (find . -path \"*/\.*\" -prune -o -type f -print -o -type l -print | sed s/^..//)) 2> /dev/null" | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
# fzf + git | |
alias gshow="git show \$(git log --pretty=oneline | fzf +m | awk '{print \$1}')" | |
alias gbranch="git checkout \$(git branch -vv | fzf +m | awk '{print \$1}' | sed \"s/.* //\")" | |
alias grebase="git rebase -i \$(git log --pretty=oneline | fzf +m | awk '{print \$1}')^" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment