^ / 003_fzf_recipes
function gb() {
branch=$(
git branch --list --sort=-committerdate \
| fzf \
--header 'ctrl-r: remote | alt-l: local | alt-f: git-fetch' \
--prompt='branch> ' \
--bind='alt-l:change-prompt(local> )+reload(git branch --list --sort=-committerdate),ctrl-r:change-prompt(remote> )+reload(git branch --all --sort=-committerdate),alt-f:execute(git fetch)' \
)
if [k9s cluster selector]; then
tr -d ' *' <<< "$branch" \
| awk '{gsub(/remotes\/origin\//,"");}1' \
| xargs git checkout
fi
}
function kc() {
cluster=$(kubectl ctx | fzf)
if [ "$cluster" = "" ]; then
printf "no clusters selected\n"
return 1
fi
k9s --context "$cluster"
}
function kn() {
cluster=$(kubectl ctx | fzf)
if [ "$cluster" = "" ]; then
printf "no clusters selected\n"
return 1
fi
selection=$(kubectl --context $cluster get --no-headers namespaces > /dev/null | fzf)
if [ "$selection" = "" ]; then
printf "no namespace selected\n"
fi
namespace=$(awk '{ print $1 }' <<< "$selection")
k9s --context "$cluster" --namespace "$namespace"
}