diff --git a/.config/git/config b/.config/git/config index 02e7abb..706ac25 100644 --- a/.config/git/config +++ b/.config/git/config @@ -32,6 +32,7 @@ ssync = "!\"${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git/git-ssync\"" submodule-rm = "!\"${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git/git-submodule-rm\"" track = "!\"${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git/git-track\"" + perm-stash = "!\"${XDG_CONFIG_HOME:-$HOME/.config}/zsh/autoload/git/git-perm-stash\"" [blame] date = short [branch] diff --git a/.config/zsh/autoload/git/git-perm-stash b/.config/zsh/autoload/git/git-perm-stash new file mode 100755 index 0000000..b90c093 --- /dev/null +++ b/.config/zsh/autoload/git/git-perm-stash @@ -0,0 +1,17 @@ +#!/usr/bin/env zsh + +emulate -L zsh -eu + +local REF_LEN DIR idx stash_ref commit_ref + +REF_LEN=8 +DIR="$HOME/gitstashes" + +git rev-parse + +idx="${1:-0}" +stash_ref="$(git rev-parse stash@{$idx} | cut -c-$REF_LEN)" +commit_ref="$(git rev-parse HEAD | cut -c-$REF_LEN)" + +git stash show -up "$idx" > \ + "${2:-$DIR}/${PWD//\//__}__${commit_ref}__$stash_ref.diff"