Last active
January 11, 2023 18:39
-
-
Save lgatto/58ef4c6fab8f637218216bc46033bf98 to your computer and use it in GitHub Desktop.
Pulls and pushes a few github repos in bash and elisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Pulls and pushes a few github repos from emacs | |
;; Laurent Gatto (https://github.com/lgatto) | |
;; Thanks to Stephen J. Eglen for his help in redirecting to a | |
;; dedicated buffer (https://github.com/sje30) | |
(setq git-dirs '( | |
"~/wd" | |
"~/bin" | |
"~/Documents/org" | |
"~/Documents/roam" | |
)) | |
(defun push-or-pull (direction) | |
"Push/pull to/from many repositories." | |
(interactive) | |
(let ((buf (get-buffer-create "*push-pull*")) | |
(shell-command-dont-erase-buffer t)) | |
(save-excursion | |
(set-buffer buf) | |
(erase-buffer)) | |
(dolist (item git-dirs) | |
(shell-command (format "echo %sing %s" (capitalize direction) item) buf) | |
(shell-command (format "cd %s; git %s" item direction) buf) | |
) | |
(pop-to-buffer buf) | |
(goto-char (point-max)) | |
) | |
) | |
(defun pull-many () | |
"Pull from many repositories." | |
(interactive) | |
(push-or-pull "pull")) | |
(defun push-many () | |
"Push to many repositories." | |
(interactive) | |
(push-or-pull "push")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dirs=( | |
~/wd | |
~/bin | |
~/Documents/attachments | |
~/Documents/org | |
~/Documents/roam) | |
for dir in ${dirs[@]} | |
do | |
echo "-> Pulling from" $dir | |
cd $dir | |
git pull | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dirs=( | |
~/wd | |
~/bin | |
~/Documents/attachments | |
~/Documents/org | |
~/Documents/roam) | |
for dir in ${dirs[@]} | |
do | |
echo "-> Pushing from" $dir | |
cd $dir | |
git push | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment