-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstashy.plugin.zsh
41 lines (38 loc) · 1.12 KB
/
stashy.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function stashy() {
local command=$1
local parameter=$2
if [[ "$parameter" == "last" ]] || ! [[ "$parameter" ]]; then
parameter="0"
fi
if [[ $command =~ ^[0-9]+$ ]]; then
git stash show stash@{$command} -p
elif [[ "$command" == "show" ]]; then
git stash show stash@{$parameter} -p
elif [[ "$command" == "list" ]]; then
git stash list -p
elif [[ "$command" == "unstaged" ]]; then
git stash --keep-index
elif [[ "$command" == "pop" ]]; then
git stash pop stash@{$parameter}
elif [[ "$command" == "apply" ]]; then
git stash apply stash@{$parameter}
elif [[ "$command" == "drop" ]]; then
git stash drop stash@{$parameter}
elif [[ "$command" == "clear" ]]; then
git stash clear
elif [[ "$command" == "all" ]]; then
git stash --include-untracked
elif [[ "$command" == "staged" ]]; then
local files=$(git diff --name-only --cached)
if [[ $files ]]; then
git stash push $files
fi
elif [[ "$command" == "patch" ]]; then
git stash --patch
elif ! [[ "$command" ]]; then
git stash
else
echo "Please enter a valid command"
fi
}
alias sta="stashy"