From c7c336777a4f4758bed81afbe21732f4cb793555 Mon Sep 17 00:00:00 2001 From: "Joakim L. Engeset" Date: Mon, 25 Nov 2024 21:20:30 +0100 Subject: [PATCH] cleanup --- bf/README.md | 3 --- bf/bb.edn | 3 --- bf/deps.edn | 1 - bf/src/bf/cli.clj | 38 --------------------------------- bf/src/bf/core.clj | 53 ---------------------------------------------- gogo | 1 - goland | 2 -- install-gopackages | 2 +- 8 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 bf/README.md delete mode 100644 bf/bb.edn delete mode 100644 bf/deps.edn delete mode 100644 bf/src/bf/cli.clj delete mode 100644 bf/src/bf/core.clj delete mode 100755 goland diff --git a/bf/README.md b/bf/README.md deleted file mode 100644 index c3dafb4..0000000 --- a/bf/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# bf - -babashka file util stuff diff --git a/bf/bb.edn b/bf/bb.edn deleted file mode 100644 index 26e9a8c..0000000 --- a/bf/bb.edn +++ /dev/null @@ -1,3 +0,0 @@ -{:paths ["src"] - :bbin/bin {bf {:ns-default bf.cli}} - :deps {io.github.joakimen/bf {:local/root "."}}} diff --git a/bf/deps.edn b/bf/deps.edn deleted file mode 100644 index 2945084..0000000 --- a/bf/deps.edn +++ /dev/null @@ -1 +0,0 @@ -{:deps {io.github.joakimen/fzf.clj {:git/sha "67e81183fc82b7153a58cf056ad8349286e7ec8e"}}} diff --git a/bf/src/bf/cli.clj b/bf/src/bf/cli.clj deleted file mode 100644 index 1cddcb3..0000000 --- a/bf/src/bf/cli.clj +++ /dev/null @@ -1,38 +0,0 @@ -(ns bf.cli - (:require [bf.core :as core])) - -(defn edit - "Select one or more file with fuzzy completion, open in nvim" - [_] - (core/fuzzy-edit)) - -(defn path - "Return the path of a file" - [_] - (core/get-file-path)) - -(defn parent-path - "Return the path of the parent-dir of a file" - [_] - (core/get-file-parent-path)) - -#_{:clj-kondo/ignore [:redefined-var]} -(defn cat - "cat a file using fuzzy selection" - [_] - (core/fuzzy-cat)) - -(defn rm - "rm a file using fuzzy selection" - [_] - (core/fuzzy-rm)) - -(defn git - "View git history of file using fuzzy selection and lazygit" - [_] - (core/fuzzy-git)) - -(defn dir - "Select a dir using fuzzy completion" - [_] - (core/select-dir)) diff --git a/bf/src/bf/core.clj b/bf/src/bf/core.clj deleted file mode 100644 index fee26a7..0000000 --- a/bf/src/bf/core.clj +++ /dev/null @@ -1,53 +0,0 @@ -(ns bf.core - (:require [babashka.fs :as fs] - [babashka.process :as p] - [clojure.string :as str] - [fzf.core :refer [fzf]])) - -(defn fuzzy-edit [] - (let [preview-commands [{:pri 1 :bin "bat" :cmd "bat --line-range :20 --number --color=always {}"} - {:pri 2 :bin "cat" :cmd "cat {}"}] - preview-cmd (->> preview-commands - (filter #(fs/which (:bin %))) - (sort-by :pri) first :cmd) - files (fzf {:multi true - :preview preview-cmd})] - (when (empty? files) - (throw (ex-info "no files selected" {:babashka/exit 1}))) - (println "opening files:") - (run! #(println "-" %) files) - (apply p/shell "nvim" "-O" files))) - -(defn get-file-path [] - (when-let [file (fzf)] - (-> file fs/absolutize str println))) - -(defn get-file-parent-path [] - (when-let [file (fzf)] - (-> file fs/absolutize fs/parent str println))) - -(defn fuzzy-cat [] - (when-let [file (fzf)] - (-> file slurp println))) - -(defn fuzzy-rm [] - (let [files (fzf {:multi true})] - (when (empty? files) - (throw (ex-info "no files selected" {:babashka/exit 1}))) - (println "deleting files") - (doseq [f files] - (println "-" f) - (fs/delete-if-exists f)))) - -(defn fuzzy-git [] - (let [file (fzf)] - (when file - (p/shell "lazygit" "-f" file)))) - -(defn select-dir [] - (let [dirs (-> (p/sh "fd" "-t" "d") - :out str/split-lines)] - (when (empty? dirs) - (throw (ex-info "no dirs found" {:babashka/exit 1}))) - (-> (fzf {:in dirs}) - fs/absolutize str println))) diff --git a/gogo b/gogo index efdec6a..4269a95 100755 --- a/gogo +++ b/gogo @@ -21,4 +21,3 @@ func main() { } EOF go run main.go -code . diff --git a/goland b/goland deleted file mode 100755 index 4e9c1ca..0000000 --- a/goland +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -open -a GoLand "${1:-.}" diff --git a/install-gopackages b/install-gopackages index db7d8ef..c77550e 100755 --- a/install-gopackages +++ b/install-gopackages @@ -6,4 +6,4 @@ while read pkg; do echo "installing go package: $pkg" go install "$pkg" -done < "$HOME/.default-go-packages +done <"$HOME/.default-go-packages"