summaryrefslogtreecommitdiff
path: root/ar/.local/bin/dmenugithub
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-29 14:28:39 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-29 14:28:39 +0900
commitcd12c95fbb657a20f256cde65a736ab0ab53e0e6 (patch)
tree6e1d11fd064404d0055d74868697dec942455320 /ar/.local/bin/dmenugithub
parentb1d3b945408f8553f181f2e36c0936d65ca599e8 (diff)
modified bin/dmenuman, created bin/dmenuconnections, created bin/dmenugithub
Diffstat (limited to 'ar/.local/bin/dmenugithub')
-rwxr-xr-xar/.local/bin/dmenugithub25
1 files changed, 25 insertions, 0 deletions
diff --git a/ar/.local/bin/dmenugithub b/ar/.local/bin/dmenugithub
new file mode 100755
index 0000000..db9d5d8
--- /dev/null
+++ b/ar/.local/bin/dmenugithub
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Clone a repository into the current directory
+clone_repo() {
+ repository=$1
+ if [ -z "${repository}" ]; then
+ echo "ERROR: You need to enter the name of the repository you wish to clone."
+ else
+ git clone "${url}${repository}"
+ fi
+}
+
+# Get all the repositories for the user with curl and GitHub API and filter only
+# the repository name from the output with sed substitution
+all_repos() {
+ curl -s "https://api.github.com/users/${user}/repos?per_page=1000" | grep -o 'git@[^"]*' |
+ sed "s/git@github.com:${user}\///g"
+}
+
+select_repo() { dmenu -p "Select a repository >" -l 10; }
+
+user="${TheSiahxyz:-$1}"
+url="https://github.com/${user}/"
+
+clone_repo "$(all_repos | select_repo)"