1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2026-03-08 02:14:47 +01:00

zsh: adding alias git graph and link it to keifu

This commit is contained in:
2026-02-28 23:19:41 +01:00
parent c8f65d1705
commit ec5bfb45d5
2 changed files with 53 additions and 12 deletions

View File

@@ -87,20 +87,59 @@ function +vi-git-stash() {
_git_intercept() { _git_intercept() {
# keifu instead of git log --graph # use keifu instead of git log --graph
if [[ "$BUFFER" =~ ^git[[:space:]]+log.*--graph ]]; then if [[ "$BUFFER" =~ ^([a-zA-Z0-9_-]+)[[:space:]]+([a-zA-Z0-9_-]+)(.*)$ ]]; then
BUFFER="keifu"
fi
if [[ "$BUFFER" =~ ^config[[:space:]]+log.*--graph ]]; then local cmd=${match[1]}
BUFFER="(cd $HOME/.dotfiles && keifu)" local subcmd=${match[2]}
fi local rest=${match[3]}
# keifu instead of config log --graph # directly via git log --graph
if [[ "$BUFFER" =~ ^config[[:space:]]+log.*--graph ]]; then if [[ "$cmd" == "git" && "$subcmd" == "log" && "$rest" == *"--graph"* ]]; then
local gitdir="$HOME/.dotfiles" BUFFER="keifu"
local worktree="$HOME" zle accept-line
BUFFER="GIT_DIR=$gitdir GIT_WORK_TREE=$worktree keifu" return
fi
# check for git-alias
if [[ "$cmd" == "git" ]]; then
local alias_expansion
alias_expansion=$(git config --get "alias.$subcmd" 2>/dev/null)
if [[ -n "$alias_expansion" && "$alias_expansion" == log*--graph* ]]; then
BUFFER="keifu"
zle accept-line
return
fi
fi
# shell-alias
if alias "$cmd" &>/dev/null; then
local expansion=$(alias "$cmd")
expansion=${expansion#*=}
expansion=${expansion#\'}
expansion=${expansion%\'}
if [[ "$expansion" =~ --git-dir=([^[:space:]]+) ]]; then
local gitdir=${match[1]}
if [[ "$subcmd" == "log" && "$rest" == *"--graph"* ]]; then
BUFFER="(cd $gitdir && keifu)"
zle accept-line
return
fi
# git-alias within shell-alias
local alias_expansion
alias_expansion=$(git --git-dir="$gitdir" config --get "alias.$subcmd" 2>/dev/null)
if [[ -n "$alias_expansion" && "$alias_expansion" == log*--graph* ]]; then
BUFFER="(cd $gitdir && keifu)"
zle accept-line
return
fi
fi
fi
fi fi
# swap main and master Fix # swap main and master Fix

View File

@@ -24,3 +24,5 @@
conflictStyle = zdiff3 conflictStyle = zdiff3
[credential] [credential]
helper = store helper = store
[alias]
graph = log --graph