git: Add perm-stash to save a stash to a file

This commit is contained in:
2023-07-18 14:30:09 +02:00
parent 35536bfa7b
commit d38ee159ed
2 changed files with 18 additions and 0 deletions

View File

@@ -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]

View File

@@ -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"