summaryrefslogtreecommitdiff
path: root/git-fzf
blob: 9ce46e75d5bab56192ddfa2c3dcba47ac18f7e6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

if [ "$1" = '--local' ] || [ "$1" = '-l' ]; then
  shift
  git_options=''
  sed_prefix=''
else
  git_options='--remote'
  sed_prefix='origin/'
fi

git branch ${git_options} 2>/dev/null \
| sed '
  s@^..'"${sed_prefix}"'@@
  t
  d
' \
| fzf \
| if [ "$#" -gt 0 ]; then
  xargs -r git "$@"
else
  cat
fi