1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-22 03:21:30 +01:00

zsh: improve fgitlog, make it a function

This commit is contained in:
bretello 2021-10-03 11:19:09 +02:00
parent 8e760f3e3e
commit cce075e29c
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
2 changed files with 22 additions and 1 deletions

View File

@ -83,7 +83,6 @@ alias venv='source .venv/bin/activate'
# Run fzf with file preview # Run fzf with file preview
alias pf="fzf --preview='BAT_STYLE='header,changes' bat --color=always {}' --bind shift-up:preview-page-up,shift-down:preview-page-down" alias pf="fzf --preview='BAT_STYLE='header,changes' bat --color=always {}' --bind shift-up:preview-page-up,shift-down:preview-page-down"
alias fgitlog="git log --oneline | fzf --multi --preview 'git -p show --color=always {+1}'"
# dvc # dvc
alias dst='dvc status' alias dst='dvc status'

View File

@ -300,6 +300,28 @@ function retry() {
# Creats a gitignore for the given argument (e.g. python, cpp, etc) # Creats a gitignore for the given argument (e.g. python, cpp, etc)
function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@; } function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@; }
# Runs git log with fzf with preview
compdef _git fgitlog=git-log
function fgitlog() {
git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60%
}
compdef _git fgitlog=git-log
git-commit-show() {
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" |
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
'f() {
set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}")
[ $# -eq 0 ] || git show --color=always $1
}
f {}' \
--bind "j:down,k:up,alt-j:preview-down,alt-k:preview-up,ctrl-f:preview-page-down,ctrl-b:preview-page-up,q:abort,ctrl-m:execute:
(grep -o '[a-f0-9]\{7\}' | head -1 |
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
{} FZF-EOF" \
--preview-window=right:60%
}
# dotfiles user functions # dotfiles user functions
if [[ -f $HOME/.dotfiles_functions ]]; then if [[ -f $HOME/.dotfiles_functions ]]; then
source "$HOME/.dotfiles_functions" source "$HOME/.dotfiles_functions"