Compare commits

..

2 Commits

Author SHA1 Message Date
74693a6b3a repo: Don't cd unnecessarily 2024-06-17 17:43:36 +10:00
854c282983 It's fine, right? 2024-06-17 17:43:06 +10:00
3 changed files with 12 additions and 3 deletions

3
fcl
View File

@ -42,6 +42,9 @@ def repo_url(repo_str)
# GitHub HTTPS. We like these, use it as-is.
when /^(git|https)\:\/\/github\.com\//
repo_str
# Other HTTPS. Assume it's fine?
when /^https\:\/\//
repo_str
# GitHub SSH. Let's convert this to HTTPS.
when /^git@github\.com\:.+\.git$/
repo_str.sub(/^git@github\.com:/, 'https://github.com/')

View File

@ -10,6 +10,7 @@
#
cat <<-EOS
repo () {
cd \$($(dirname $(realpath ${BASH_SOURCE[0]}))/repo \$@)
r=\$($(dirname $(realpath ${BASH_SOURCE[0]}))/repo \$@)
[[ "\$r" != "." ]] && [[ "\$r" != "\$(pwd)/" ]] && cd \$r
}
EOS

7
repo
View File

@ -27,9 +27,14 @@ repos=$(find "${REPOSITORY_BASE}" -maxdepth 5 -name '.git' | sed "s|${REPOSITORY
# 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 "${REPO_DEFAULT_SEARCH_PREFIX}${1}" --prompt="Repo: ")"
selected="$(echo "${repos}" | fzf -1 -0 -q "${1:-${REPO_DEFAULT_SEARCH_PREFIX}}" --prompt="Repo: ")"
# Do nothing if no repo was selected
if [ -n "${selected}" ]; then
echo "${REPOSITORY_BASE}/${selected}"
else
echo '.'
fi
# TODO: It could be super nice to bias in favour of more frequently selected options.
# For the last 500 uses (or so):