summaryrefslogtreecommitdiff
path: root/git-fzf
diff options
context:
space:
mode:
Diffstat (limited to 'git-fzf')
-rwxr-xr-xgit-fzf23
1 files changed, 23 insertions, 0 deletions
diff --git a/git-fzf b/git-fzf
new file mode 100755
index 0000000..9ce46e7
--- /dev/null
+++ b/git-fzf
@@ -0,0 +1,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