git: Add perm-stash to save a stash to a file
This commit is contained in:
@@ -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]
|
||||
|
||||
17
.config/zsh/autoload/git/git-perm-stash
Executable file
17
.config/zsh/autoload/git/git-perm-stash
Executable 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"
|
||||
Reference in New Issue
Block a user