Last active
October 31, 2016 07:55
-
-
Save mizukmb/cf8c5ab16b647c2ff262bf3804b0c0aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
case "$1" in | |
-a|--all) | |
git branch --sort=-authordate -v -a | peco | sed -e 's/*/ /' | sed -e 's/ //' | cut -d ' ' -f1 | xargs git checkout | |
;; | |
-r|--remotes) | |
git branch --sort=-authordate -v -r | peco | sed -e 's/*/ /' | sed -e 's/ //' | cut -d ' ' -f1 | xargs git checkout | |
;; | |
*) | |
git branch --sort=-authordate -v | peco | sed -e 's/*/ /' | sed -e 's/ //' | cut -d ' ' -f1 | xargs git checkout | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sed -e 's/*/ /' | sed -e 's/ //'
はsed -E -e 's/^[* ]+//'
で良さそうです(OSX の場合)。さらに重複を減らすとこうなりますね。Bash 記法はないので、Bourne Shell で良さそう。