bb ebook-to-audiobook the-great-gatsby.epub
```
-There are a utility file that makes running the tasks easier. Load it up first.
-You can also add the following line with the absolute path to the file in your "~/.profile" file.
+## Shell aliases
``` sh
-source bb-aliases.sh
+# bash, zsh
+source /path/to/babashka-scripts/bb-aliases.sh
+alias task = bb --config ~/dev/babashka-scripts/bb.edn
+
+# nu
+source /path/to/babashka-scripts/bb-aliases.nu
+alias task = bb --config ~/dev/babashka-scripts/bb.edn
+```
+
+*Example:* To pull all the repositories in a directory, run
+
+``` sh
+task gpa .
```
+There is a utility `bbe` to run tasks in the current working directory in `bb-aliases.sh`.
+
+
*Example:* To pull all the repositories in a directory, run
``` sh
{:paths ["scripts"]
:tasks
- {gup {:requires ([git :refer [git-pull-rebase-branch]])
+ {test {:doc "Test whether the 'task' alias is working."
+ :task (println "Yes, it's working!")}
+
+ gup {:requires ([git :refer [git-pull-rebase-branch]])
:doc "Do a git pull and rebase branch with master in a given directory."
:task (git-pull-rebase-branch (get (into [] *command-line-args*) 0))}
; Utilities for git operations
-(def default-root ".")
-
(defn- has-git-repo
[dir]
(first (filter #(= ".git" %)
(filter #(has-git-repo %)
(filter #(.isDirectory %) (.listFiles (io/file root)))))
-(defn- git-pull [dir]
+(defn- git-pull
+ "Do a git pull with rebase."
+ [dir]
(p/process ["git" "-C" dir "pull" "--rebase"]))
(defn git-pull-all
- "Runs `git-pull` on all the git repositories in a directory"
+ "Runs `git-pull` on all the git repositories in a directory."
[root]
(let [dirs (list-dirs root)
pulls (->> root
p/check
:out
slurp)
- pulls)]
+ pulls)]
;; Print corresponding directory name when pulling
;; Skip printing already up to date repos
(doseq [[dir out] (filter #(not (.contains (second %) "is up to date."))
- (map vector dirs outputs))]
+ (map vector dirs outputs))]
(println (str dir "\n" out)))))
(defn git-pull-rebase-branch
- "Do git pull and rebase branch with master"
+ "Do git pull and rebase branch with master."
[dir]
+ (git-pull dir)
(let [current-branch (str/trim (run-cmd ["git" "branch" "--show-current"]))]
- (git-pull dir)
(when (not (contains? #{"master" "main"} current-branch))
(run! print
(map run-cmd
- '[["git" "checkout" "master"]
- ["git" "pull" "--rebase"]
- ["git" "checkout" "-"]
- ["git" "rebase" "master"]])))))
+ [["git" "checkout" "master"] ["git" "pull" "--rebase"]
+ ["git" "checkout" current-branch] ["git" "rebase" "master"]])))))