From b804819c6f671c1d08daada9f7b5a9811c9f099e Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sat, 27 Jul 2024 12:22:30 +0300 Subject: [PATCH] config/git: improve aliases --- .config/git/config | 2 +- .config/shell/git | 3 +-- .local/bin/scripts/git-pathhook | 4 ++++ .local/bin/scripts/git-repo | 9 ++++----- 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100755 .local/bin/scripts/git-pathhook diff --git a/.config/git/config b/.config/git/config index 84597f2..4d8f15d 100644 --- a/.config/git/config +++ b/.config/git/config @@ -148,7 +148,7 @@ cme = commit -v --edit --message # Commit with message from CLI but edit it cad = !git diff-tree --no-commit-id --name-only -r HEAD | git commit -v --amend --pathspec-from-file=- # Amend commit with all already changed files cap = !git commit --amend --no-edit && git push --force-with-lease - journal = !git -C $DATA commit -v $DATA/2-box/journal* + journal = !command git -C $DATA commit -v $DATA/2-box/journal* cp = cherry-pick cpc = cherry-pick --continue diff --git a/.config/shell/git b/.config/shell/git index 79575c6..2c9d355 100644 --- a/.config/shell/git +++ b/.config/shell/git @@ -37,8 +37,7 @@ gcn() { # if in home or under XDG_CONFIG_HOME and not within a git directory, replace git by yadm git() { case "$1" in - (config) ;; - (clone) ;; + (config|clone|journal) ;; (*) case "$PWD" in ($HOME|$XDG_CONFIG_HOME|$LAST_YADM) yadm "$@" diff --git a/.local/bin/scripts/git-pathhook b/.local/bin/scripts/git-pathhook new file mode 100755 index 0000000..7e2f68a --- /dev/null +++ b/.local/bin/scripts/git-pathhook @@ -0,0 +1,4 @@ +#!/bin/sh -ex +# Configure git prepare-commit-msg hook that prefixes common path of changed files +git config core.hooksPath .git/hooks +ln -st .git/hooks $XDG_CONFIG_HOME/git/prepare-commit-msg diff --git a/.local/bin/scripts/git-repo b/.local/bin/scripts/git-repo index 70faec5..72e60a7 100755 --- a/.local/bin/scripts/git-repo +++ b/.local/bin/scripts/git-repo @@ -16,11 +16,10 @@ case "$1" in esac host=$1 case $host in - (socha) user=software-challenge; host=git@github.com;; - (hub|github) host=git@github.com;; - (lab) host=git@gitlab.com;; - (jf) host=gitea@git.jfischer.org;; - (ftt|"") host=git@forge.ftt.gmbh; user=janek;; + (socha) user=software-challenge; host=github.com;; + (hub|github) host=github.com;; + (lab) host=gitlab.com;; + (ftt|"") host=forge.ftt.gmbh; user=janek;; esac user=${3:-${user:-$(git config user.name)}} repo=${2:-$(basename $(git root))}