summaryrefslogtreecommitdiff
path: root/shell-scripts/gh-switch-project
diff options
context:
space:
mode:
authorMike Vink <>2023-04-04 13:57:50 +0200
committerMike Vink <>2023-04-04 13:57:50 +0200
commit32bb27d1ed3f7d74bce0e6c143692a61e4736dde (patch)
tree1d5729d27f2aa45e64daeefffc38d3ffea5fc36a /shell-scripts/gh-switch-project
parenteb4f40576452137ac0a2c5d4ef079e7aca188b76 (diff)
add gh-switch-project
Diffstat (limited to 'shell-scripts/gh-switch-project')
-rw-r--r--shell-scripts/gh-switch-project15
1 files changed, 15 insertions, 0 deletions
diff --git a/shell-scripts/gh-switch-project b/shell-scripts/gh-switch-project
new file mode 100644
index 0000000..b7054ca
--- /dev/null
+++ b/shell-scripts/gh-switch-project
@@ -0,0 +1,15 @@
+#!@bash@/bin/bash
+eval "$(pass show personal/shell-scripts/secrets)"
+repo=$(gh repo list --json owner,name -q '.[] | "\(.owner.login)/\(.name)"' | fzf)
+GIT_DIR="$HOME/projects"
+if [ ! -d $GIT_DIR ]; then
+ mkdir -p $GIT_DIR
+fi
+
+DEST_DIR="$GIT_DIR/$(echo $repo | cut -d '/' -f2)"
+if [ ! -d $DEST_DIR ]
+then
+ gh repo clone $repo $DEST_DIR
+fi
+cd $DEST_DIR
+$EDITOR