1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2026-03-09 18:54:47 +01:00

Compare commits

..

3 Commits

Author SHA1 Message Date
e9d5b3ecd4 profile: added ydotool socket path 2026-02-28 23:22:48 +01:00
ec5bfb45d5 zsh: adding alias git graph and link it to keifu 2026-02-28 23:19:41 +01:00
c8f65d1705 zsh: added keifu fix 2026-02-28 13:30:16 +01:00
3 changed files with 67 additions and 9 deletions

View File

@@ -85,28 +85,82 @@ function +vi-git-stash() {
# CUSTOM WIDGETS # # CUSTOM WIDGETS #
################## ##################
_git_fix_main_master() { _git_intercept() {
# use keifu instead of git log --graph
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"
zle accept-line
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
# swap main and master Fix
if [[ $BUFFER == git\ * ]]; then if [[ $BUFFER == git\ * ]]; then
local has_main=0 local has_main=0
local has_master=0 local has_master=0
git rev-parse --verify main >/dev/null 2>&1 && has_main=1 git rev-parse --verify main >/dev/null 2>&1 && has_main=1
git rev-parse --verify master >/dev/null 2>&1 && has_master=1 git rev-parse --verify master >/dev/null 2>&1 && has_master=1
if [[ $has_main -eq 1 && $has_master -eq 0 ]]; then if [[ $has_main -eq 1 && $has_master -eq 0 ]]; then
if [[ $BUFFER == *" master"* ]]; then BUFFER=${BUFFER//" master"/" main"}
BUFFER=${BUFFER//" master"/" main"}
fi
fi fi
if [[ $has_master -eq 1 && $has_main -eq 0 ]]; then if [[ $has_master -eq 1 && $has_main -eq 0 ]]; then
if [[ $BUFFER == *" main"* ]]; then BUFFER=${BUFFER//" main"/" master"}
BUFFER=${BUFFER//" main"/" master"}
fi
fi fi
fi fi
zle accept-line zle accept-line
} }
zle -N _git_fix_main_master zle -N _git_intercept
bindkey "^M" _git_fix_main_master bindkey "^M" _git_intercept
######### #########
# STYLE # # STYLE #

View File

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

View File

@@ -48,6 +48,8 @@ export CUDA_DIR="/opt/cuda"
export CUDA_PATH="/opt/cuda" export CUDA_PATH="/opt/cuda"
export XLA_FLAGS=--xla_gpu_cuda_data_dir=/opt/cuda export XLA_FLAGS=--xla_gpu_cuda_data_dir=/opt/cuda
export YDOTOOL_SOCKET="$HOME/.ydotool_socket"
# external programs # external programs
export OPENAUDIBLE_HOME="${HOME}/documents/openaudible" export OPENAUDIBLE_HOME="${HOME}/documents/openaudible"