Compare commits

..

3 Commits

Author SHA1 Message Date
69ab075c80 init: actually work 2024-05-19 22:51:56 +10:00
9603b7bedf braces++ 2024-05-19 22:51:26 +10:00
40b0943fff Move repo search prefix out to config 2024-05-19 22:51:06 +10:00
4 changed files with 18 additions and 9 deletions

View File

@ -7,4 +7,4 @@ REPOSITORY_BASE=~/src
# If a variable is only to be used by a single script, by custom it will be # If a variable is only to be used by a single script, by custom it will be
# prefixed with the name of the script. # prefixed with the name of the script.
REPO_DEFAULT_SEARCH_PREFIX="github.com/buildkite" REPO_DEFAULT_SEARCH_PREFIX="github.com/buildkite/"

15
init-repo-tools Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
#
# Call this your shell config, e.g. ~/.zshrc, and eval the results, e.g.:
#
# eval "$(/path/to/this/repo/init-repo-tools)"
#
# Bash scripts can't change the working directory of their callers. This is
# right and proper, but changing working directory is `repo`'s entire purpose,
# so we need to work around that restriction.
#
cat <<-EOS
repo () {
cd \$($(dirname $(realpath ${BASH_SOURCE[0]}))/repo \$@)
}
EOS

View File

@ -1,6 +0,0 @@
# Source this into your shell config, e.g. ~/.zshrc
# Bash scripts can't change the working directory of their callers. This is
# right and proper, but we need to work around it in this case.
#
repo () { cd $($(dirname ${BASH_SOURCE[0]})/repo $@) }

4
repo
View File

@ -27,9 +27,9 @@ repos=$(find "${REPOSITORY_BASE}" -name '.git' | sed "s|${REPO_BASE}/||" | sed '
# 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 "${REPO_DEFAULT_SEARCH_PREFIX}${1}" --prompt="Repo: ")"
echo "$REPOSITORY_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):