diff --git a/local/bin/git-coi b/local/bin/git-coi index ef6fe4b..00a7f3e 100755 --- a/local/bin/git-coi +++ b/local/bin/git-coi @@ -1,5 +1,20 @@ #!/bin/sh -git branch $@ | - cut -c 3- | - fzf --reverse --preview 'git log --patch --color {}...{}~5' | - xargs git checkout +case $1 in + -a) + heads=refs/heads + remotes=refs/remotes + ;; + -r) + remotes=refs/remotes + ;; + *) + heads=refs/heads + ;; +esac + +git for-each-ref \ + --sort=-committerdate \ + --format='%(refname:short) (%(committerdate:relative))' \ + $heads $remotes \ + | fzf --reverse --preview 'git log --patch --color {1}...{1}~5' \ + | awk '{print $1}' | xargs git checkout