#!/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