update git checkout functions for mac
This commit is contained in:
parent
f728ad7ecd
commit
b1ba713659
1 changed files with 24 additions and 1 deletions
25
zsh/.zshrc
25
zsh/.zshrc
|
|
@ -83,7 +83,7 @@ fcd() {
|
|||
|
||||
# clone repository
|
||||
# setopt EXTENDED_GLOB
|
||||
gc() {
|
||||
cl() {
|
||||
local url=$1
|
||||
local ghq_dir="$HOME/ghq"
|
||||
|
||||
|
|
@ -120,6 +120,29 @@ git-prune() {
|
|||
git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs git branch -d
|
||||
}
|
||||
|
||||
# fuzzy find branches and switch to selected branch
|
||||
gc() {
|
||||
local selected_branch=$(git branch | fzf | sed 's/^[ \*]*//')
|
||||
|
||||
if [ -n "$selected_branch" ]; then
|
||||
git checkout "$selected_branch"
|
||||
else
|
||||
echo "No branch selected"
|
||||
fi
|
||||
}
|
||||
|
||||
# fuzzy find remote branches and switch to selected branch
|
||||
gcr() {
|
||||
git fetch
|
||||
local selected_branch=$(git branch -r | fzf | sed -E 's/^([ \*]*origin\/[\ *]*)*//')
|
||||
|
||||
if [ -n "$selected_branch" ]; then
|
||||
git checkout "$selected_branch"
|
||||
else
|
||||
echo "No branch selected"
|
||||
fi
|
||||
}
|
||||
|
||||
# Load colors if possible
|
||||
autoload -U colors && colors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue