blob: 0dd5d31272fb83936664585b76d33a5dbae6a896 (
plain)
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
42
|
#!/bin/sh
# shellcheck disable=SC2088
dest=$(
find ~/git -mindepth 1 -maxdepth 1 -printf '%A@\t%f\n' |
sort -r |
cut -f 2 |
dmenu -l 10 -p '~/git/'
)
[ -z "$dest" ] && exit 1
dest_path="$HOME/git/$dest"
if cd "$dest_path" 2> /dev/null
then
touch "$dest_path"
st
else
while [ -z "$choice" ]
do
choice=$(printf 'create\nclone\ncancel' | dmenu -p "New repository at ~/git/$dest?")
done
case "$choice" in
"create")
mkdir -p "$dest_path"
cd "$dest_path" || exit 1
git init
;;
"clone")
url="$(echo '' | dmenu -p "Entry repository url: ")"
notify-send "Cloning $url to $dest_path"
git clone --recursive "$url" "$dest_path" ||
(notify-send -u critical "Clone failed"; exit 1)
cd "$dest_path" || exit 1
;;
"cancel") exit ;;
*) exit 1 ;;
esac
st
fi
|