Guest User

Untitled

a guest
Apr 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #!/usr/local/bin/bash
  2.  
  3. str="/$*/"
  4. str=$(echo "$str" | sed 's/ /\/ \&\& \//g')
  5. str="print if $str"
  6. res=$(git branch --all | perl -ne "$str")
  7. res=$(echo $res | tr ' ' '\n' | cut -d/ -f3-)
  8. matches=$(echo $res | tr ' ' '\n' | uniq -u | wc -l)
  9. if (( $matches == 1 )); then
  10. git checkout "$res"
  11. else
  12. echo $res | tr ' ' '\n'
  13. fi
Add Comment
Please, Sign In to add comment