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:
@@ -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
|
||||||
|
|
||||||
|
local cmd=${match[1]}
|
||||||
|
local subcmd=${match[2]}
|
||||||
|
local rest=${match[3]}
|
||||||
|
|
||||||
|
# directly via git log --graph
|
||||||
|
if [[ "$cmd" == "git" && "$subcmd" == "log" && "$rest" == *"--graph"* ]]; then
|
||||||
BUFFER="keifu"
|
BUFFER="keifu"
|
||||||
|
zle accept-line
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$BUFFER" =~ ^config[[:space:]]+log.*--graph ]]; then
|
# check for git-alias
|
||||||
BUFFER="(cd $HOME/.dotfiles && keifu)"
|
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
|
fi
|
||||||
|
|
||||||
# keifu instead of config log --graph
|
# shell-alias
|
||||||
if [[ "$BUFFER" =~ ^config[[:space:]]+log.*--graph ]]; then
|
if alias "$cmd" &>/dev/null; then
|
||||||
local gitdir="$HOME/.dotfiles"
|
local expansion=$(alias "$cmd")
|
||||||
local worktree="$HOME"
|
expansion=${expansion#*=}
|
||||||
BUFFER="GIT_DIR=$gitdir GIT_WORK_TREE=$worktree keifu"
|
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
|
||||||
|
|||||||
@@ -24,3 +24,5 @@
|
|||||||
conflictStyle = zdiff3
|
conflictStyle = zdiff3
|
||||||
[credential]
|
[credential]
|
||||||
helper = store
|
helper = store
|
||||||
|
[alias]
|
||||||
|
graph = log --graph
|
||||||
|
|||||||
Reference in New Issue
Block a user