mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-19 09:03:43 -05:00
use arrays instead of piping to head and tail in fstash
38
Examples.md
38
Examples.md
@@ -338,24 +338,26 @@ fcs() {
|
|||||||
# ctrl-b checks the stash out as a branch, for easier merging
|
# ctrl-b checks the stash out as a branch, for easier merging
|
||||||
fstash() {
|
fstash() {
|
||||||
local out q k sha
|
local out q k sha
|
||||||
while out=$(
|
while out=$(
|
||||||
git stash list --pretty="%C(yellow)%h %>(14)%Cgreen%cr %C(blue)%gs" |
|
git stash list --pretty="%C(yellow)%h %>(14)%Cgreen%cr %C(blue)%gs" |
|
||||||
fzf --ansi --no-sort --query="$q" --print-query \
|
fzf --ansi --no-sort --query="$q" --print-query \
|
||||||
--expect=ctrl-d,ctrl-b);
|
--expect=ctrl-d,ctrl-b);
|
||||||
do
|
do
|
||||||
q=$(head -1 <<< "$out")
|
mapfile -t out <<< "$out"
|
||||||
k=$(head -2 <<< "$out" | tail -1)
|
q="${out[0]}"
|
||||||
sha=$(tail -1 <<< "$out" | cut -d' ' -f1)
|
k="${out[1]}"
|
||||||
[ -z "$sha" ] && continue
|
sha="${out[-1]}"
|
||||||
if [ "$k" = 'ctrl-d' ]; then
|
sha="${sha%% *}"
|
||||||
git diff $sha
|
[[ -z "$sha" ]] && continue
|
||||||
elif [ "$k" = 'ctrl-b' ]; then
|
if [[ "$k" = 'ctrl-d' ]]; then
|
||||||
git stash branch "stash-$sha" $sha
|
git diff $sha
|
||||||
break;
|
elif [[ "$k" = 'ctrl-b' ]]; then
|
||||||
else
|
git stash branch "stash-$sha" $sha
|
||||||
git stash show -p $sha
|
break;
|
||||||
fi
|
else
|
||||||
done
|
git stash show -p $sha
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
### Tags
|
### Tags
|
||||||
|
|||||||
Reference in New Issue
Block a user