From 9f0c26168043f2bd2ba79b8f89ee85d08e4dbc76 Mon Sep 17 00:00:00 2001 From: Wenxuan Zhang Date: Fri, 17 Apr 2020 12:29:21 +0800 Subject: [PATCH] feat: support commit ref parameters for glo. #85 Former-commit-id: bd67dcbddd3ff8fd92c048cccdc0e3129bac33e5 --- README.md | 2 +- forgit.plugin.zsh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4749755..9156147 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ FORGIT_STASH_FZF_OPTS=' ## Tips - Hit `q` to quit from full screen preview any time. -- Commands like `glo`, `gd`, `gcf` and `gclean` accept path arguments to restrain the items listed in fzf(eg, `glo main.go test.go`, `gclean output/`). +- Commands like `glo`, `gd`, `gcf` and `gclean` accept arguments to restrain the items listed in fzf(eg, `glo develop`, `glo f738479..188a849b -- main.go`, `gclean output/` etc.). - `gd` supports specifying revision(eg, `gd HEAD~`, `gd v1.0 README.md`). - Call `gi` with arguments to get the wanted `.gitignore` contents directly(eg, `gi cmake c++`). diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index f11fe57..c061b70 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -11,8 +11,9 @@ forgit_pager=$(git config core.pager || echo 'cat') # git commit viewer forgit::log() { forgit::inside_work_tree || return 1 - local cmd opts graph - cmd="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % $* | $forgit_pager" + local cmd opts graph files + files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*") + cmd="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_pager" opts=" $FORGIT_FZF_DEFAULT_OPTS +s +m --tiebreak=index