repo: Many enhancements

- Do a better job at finding repos
- Use common config
- Refer to init.bash in comments
This commit is contained in:
2024-05-19 22:21:22 +10:00
parent 17159b20c1
commit 866123d4fb

18
repo
View File

@ -8,26 +8,28 @@
# #
# So yeah. Here's this thing. # So yeah. Here's this thing.
# #
# GOTCHA: (also, setup instructions) # NOT WORKING?
# #
# Bash scripts can't change the working directory of their callers. This is # Since shell scripts can't change the working directories of their callers (as
# right and proper, but we need to work around it in this case. # is right and proper), this script can only do its job if it's called by a
# # function, e.g.:
# To use this script, create a function in your .bashrc or .zshrc:
# #
# repo() { cd $(/path/to/this/script $@) } # repo() { cd $(/path/to/this/script $@) }
# #
# If you add 'source /path/to/this/repo/init.bash' to your shell rc file (e.g.
# ~/.zshrc), this (and perhaps some other goodies) will be set up for you.
#
REPO_BASE=${HOME}/src source $(dirname ${BASH_SOURCE[0]})/config.bash
repos=$(find -s "${REPO_BASE}" -maxdepth 3 -mindepth 3 -type d -not -path "${REPO_BASE}/repo-tools/*" | sed "s|${REPO_BASE}/||") repos=$(find "${REPOSITORY_BASE}" -name '.git' | sed "s|${REPO_BASE}/||" | sed 's|.git$||' | sort)
# Default to searching within github.com, because that's by far the most common # Default to searching within github.com, because that's by far the most common
# place for repos to be. # place for repos to be.
# selected=$(echo "${repos}" | gum filter --header="Pick a repo" --prompt="Repo: " --height=20 --value "github.com/${1}") # selected=$(echo "${repos}" | gum filter --header="Pick a repo" --prompt="Repo: " --height=20 --value "github.com/${1}")
selected="$(echo "${repos}" | fzf -1 -0 -q "github.com/buildkite/${1}" --prompt="Repo: ")" selected="$(echo "${repos}" | fzf -1 -0 -q "github.com/buildkite/${1}" --prompt="Repo: ")"
echo "$REPO_BASE/$selected" echo "$REPOSITORY_BASE/$selected"
# TODO: It could be super nice to bias in favour of more frequently selected options. # TODO: It could be super nice to bias in favour of more frequently selected options.
# For the last 500 uses (or so): # For the last 500 uses (or so):