summaryrefslogtreecommitdiff
path: root/common/bin/browse-git
diff options
context:
space:
mode:
Diffstat (limited to 'common/bin/browse-git')
-rwxr-xr-xcommon/bin/browse-git19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/bin/browse-git b/common/bin/browse-git
new file mode 100755
index 0000000..2eb9f8f
--- /dev/null
+++ b/common/bin/browse-git
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+dldir="$HOME/Downloads"
+if [ "$XDG_DOWNLOAD_DIR" ]; then
+ dldir="$XDG_DOWNLOAD_DIR"
+elif (which xdg-user-dir >/dev/null 2>&1) && [ "$(xdg-user-dir DOWNLOAD)" ]; then
+ dldir="$(xdg-user-dir DOWNLOAD)"
+fi
+
+mkdir -p "$dldir"
+cd "$dldir"
+
+gitdir="$(basename -s .git "$1")"
+test -e "$gitdir" && exit 1
+
+git clone "$1" --depth=1 "$gitdir"
+test "$EDITOR" || EDITOR="emacsclient"
+emacsclient "$gitdir"
+rm -rf "$gitdir"