Compare commits
4 Commits
708daa10dc
...
6db1a710c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
6db1a710c6
|
|||
|
9c1e3f4679
|
|||
|
bb7ef3769d
|
|||
|
0534ec493e
|
@@ -4,21 +4,22 @@
|
||||
addIgnoredFile = off
|
||||
detachedHead = off
|
||||
[alias]
|
||||
# NOTE: git-zsh-autoload (./zsh-autoload.sh) is a small wrapper that
|
||||
# launches autoloadable zsh functions (.config/zsh/autoload/git/*) in
|
||||
# the right directory, as shell commands in git aliases are executed
|
||||
# from the top-level directory of the repository.
|
||||
# NOTE: git-external-script (./external-script.sh) is a small wrapper
|
||||
# that launches external scripts from the ./scripts/ collection in the
|
||||
# right directory, as shell commands in git aliases are executed from
|
||||
# the top-level directory of the repository.
|
||||
|
||||
abort = "!git-zsh-autoload abort"
|
||||
abort = "!git-external-script abort"
|
||||
autosquash = -c sequence.editor=/bin/true rebase -i --autosquash
|
||||
autofixup= autosquash
|
||||
branch-rename = "!git-external-script branch-rename"
|
||||
c = commit
|
||||
changes = flog HEAD...FETCH_HEAD
|
||||
checkout-worktree = "!git-zsh-autoload checkout-worktree"
|
||||
checkout-worktree = "!git-external-script checkout-worktree"
|
||||
cow = checkout-worktree
|
||||
co = checkout
|
||||
commit-last-msg = "!git-zsh-autoload commit-last-msg"
|
||||
continue = "!git-zsh-autoload continue"
|
||||
commit-last-msg = "!git-external-script commit-last-msg"
|
||||
continue = "!git-external-script continue"
|
||||
cont = continue
|
||||
clm = commit-last-msg
|
||||
last-msg = commit-last-msg
|
||||
@@ -28,21 +29,21 @@
|
||||
ft = fetch-tags-only
|
||||
filter-repo = !git-filter-repo
|
||||
fixes = log -1 --pretty=fixes
|
||||
glog = "!git-zsh-autoload glog"
|
||||
https-and-ssh = "!git-zsh-autoload https-and-ssh"
|
||||
glog = "!git-external-script glog"
|
||||
https-and-ssh = "!git-external-script https-and-ssh"
|
||||
ssh-and-https = https-and-ssh
|
||||
l = log
|
||||
last-changed = "!git-zsh-autoload last-changed"
|
||||
last-changed = "!git-external-script last-changed"
|
||||
ls = ls-files
|
||||
make-fork = "!git-zsh-autoload make-fork"
|
||||
make-fork = "!git-external-script make-fork"
|
||||
p = push
|
||||
perm-stash = "!git-zsh-autoload perm-stash"
|
||||
perm-stash = "!git-external-script perm-stash"
|
||||
root = rev-parse --show-toplevel
|
||||
signoff = rebase --signoff
|
||||
ss = stash
|
||||
ssync = "!git-zsh-autoload ssync"
|
||||
submodule-rm = "!git-zsh-autoload submodule-rm"
|
||||
track = "!git-zsh-autoload track"
|
||||
ssync = "!git-external-script ssync"
|
||||
submodule-rm = "!git-external-script submodule-rm"
|
||||
track = "!git-external-script track"
|
||||
branches = track
|
||||
[blame]
|
||||
date = short
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Julian Prein
|
||||
#
|
||||
# Meant to be used in git aliases to launch an autoloadable zsh function in the
|
||||
# correct directory.
|
||||
# Meant to be used by git aliases to easily launch an external script from the
|
||||
# ./scripts/ collection through its basename and in the correct directory (i.e.
|
||||
# GIT_PREFIX).
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
printf >&2 "Usage: %s <function>\n" "$(basename "$0")"
|
||||
@@ -12,7 +13,7 @@ fi
|
||||
name="$1"
|
||||
shift
|
||||
|
||||
BASE="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git"
|
||||
BASE="$(dirname "$(realpath "$0")")/scripts"
|
||||
|
||||
# In git aliases, shell commands are executed from the top-level directory of
|
||||
# the repo. GIT_PREFIX contains the original directory relative to the
|
||||
26
.config/zsh/autoload/git/git-branch-rename
Executable file
26
.config/zsh/autoload/git/git-branch-rename
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env zsh
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2025 Julian Prein
|
||||
#
|
||||
# Rename a branch locally and on a given remote.
|
||||
|
||||
emulate -L zsh -o err_return -o no_unset
|
||||
|
||||
if (( # < 2 || # > 3 )); then
|
||||
printf >&2 "Usage: %s OLD NEW [REMOTE]\n" "${0:t}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local old new remote
|
||||
old="$1"
|
||||
new="$2"
|
||||
remote="${3:-origin}"
|
||||
|
||||
if ! git remote -v | awk '{ print $1 }' | uniq | grep -q "$remote"; then
|
||||
printf >&2 "Remote '%s' does not exist\n" "$remote"
|
||||
return 1
|
||||
fi
|
||||
|
||||
git checkout-worktree "$old" <<EOF
|
||||
git branch -m "$new" && git push -u && git push -d "$remote" "$old"
|
||||
EOF
|
||||
@@ -128,7 +128,7 @@ fi
|
||||
# Use a reasonable time format
|
||||
alias date='env LC_TIME=tk_TM date'
|
||||
# List human readable sizes in order
|
||||
alias sizes='du -sch * | sort -h'
|
||||
alias sizes='() { du -sch ${1:-*} "${@[2,-1]}" | sort -h }'
|
||||
# Count number of occurrences for every line in stdin
|
||||
alias count='sort | uniq -c | sort -n'
|
||||
# Inspired by https://stackoverflow.com/a/54541337
|
||||
|
||||
1
.local/bin/git-external-script
Symbolic link
1
.local/bin/git-external-script
Symbolic link
@@ -0,0 +1 @@
|
||||
../../.config/git/external-script.sh
|
||||
@@ -1 +0,0 @@
|
||||
../../.config/git/zsh-autoload.sh
|
||||
Reference in New Issue
Block a user