-(ns utils
- (:require [lib :refer [run-cmd]]
- [clojure.string :as str]))
-
-(defn git-pull-rebase-branch
- "Do git pull and rebase branch with master"
- []
- (let [current-branch (str/trim (run-cmd ["git" "branch" "--show-current"]))]
- (print (run-cmd ["git" "pull" "--rebase"]))
- (when (not (contains? #{"master" "main"} current-branch))
- (run! print
- (map run-cmd
- '[["git" "checkout" "master"]
- ["git" "pull" "--rebase"]
- ["git" "checkout" "-"]
- ["git" "rebase" "master"]])))))
-
-(defn run-seq
- "Run a sequence of shell commands on a sequence of arguments.
-
- Examples:
-
- 1. Play and delete each video from a folder
- ls | bb -i '(run-seq ["mpv" "rm"] *input*)'
- "
- [commands arguments]
- (doseq [argument arguments
- command commands]
- (println (run-cmd [command argument]))))