diff options
author | Guangxiong Lin <[email protected]> | 2021-09-20 20:43:32 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2021-09-20 20:43:32 +0800 |
commit | 7e162147d967dd63dff24ac24bf190d868ef4d29 (patch) | |
tree | bbea3b57f26688977097158bbb3615b1c1ce4a8c | |
parent | 2b03177ac4ec96972eb59a33db32f9f93a1341b0 (diff) | |
download | dotfiles-7e162147d967dd63dff24ac24bf190d868ef4d29.tar.gz dotfiles-7e162147d967dd63dff24ac24bf190d868ef4d29.tar.bz2 dotfiles-7e162147d967dd63dff24ac24bf190d868ef4d29.zip |
Add function fco
-rw-r--r-- | .functions | 16 | ||||
-rw-r--r-- | .zshrc | 1 | ||||
-rwxr-xr-x | bootstrap.sh | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/.functions b/.functions new file mode 100644 index 0000000..07f9afe --- /dev/null +++ b/.functions @@ -0,0 +1,16 @@ +fco () { + local tags branches target + branches=$( + git --no-pager branch --all \ + --format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \ + | sed '/^$/d' + ) || return + tags=$( + git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}' + ) || return + target=$( + (echo $branches; echo $tags) \ + | fzf --no-hscroll --no-multi -n 2 --ansi + ) || return + git checkout $(awk '{print $2}' <<<$target) +} @@ -61,4 +61,5 @@ fi zplug load source $HOME/.aliases +source $HOME/.functions [ -f $HOME/.zsh_local ] && source $HOME/.zsh_local diff --git a/bootstrap.sh b/bootstrap.sh index de9726d..c45122d 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -19,7 +19,7 @@ remove_and_link () { link_all () { remove_and_link .ctags.d .mutt bin .aliases .macos \ .mbsyncrc .msmtprc .tmux.conf .urlview .zshrc \ - .vimrc .vim .path + .vimrc .vim .path .functions } main () { |