repo: Many enhancements
- Do a better job at finding repos - Use common config - Refer to init.bash in comments
This commit is contained in:
18
repo
18
repo
@ -8,26 +8,28 @@
|
||||
#
|
||||
# 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
|
||||
# right and proper, but we need to work around it in this case.
|
||||
#
|
||||
# To use this script, create a function in your .bashrc or .zshrc:
|
||||
# Since shell scripts can't change the working directories of their callers (as
|
||||
# is right and proper), this script can only do its job if it's called by a
|
||||
# function, e.g.:
|
||||
#
|
||||
# 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
|
||||
# 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}" | 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.
|
||||
# For the last 500 uses (or so):
|
||||
|
||||
Reference in New Issue
Block a user