m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 08:13:40 -05:00

Add fgst() to pick files of command git status -s

Haishan Zhou
2018-05-24 14:53:42 +08:00
parent c54d3bc572
commit 7398cc1948

@@ -504,6 +504,25 @@ Create a gitignore file from [gitignore.io](http://gitignore.io):
https://gist.github.com/phha/cb4f4bb07519dc494609792fb918e167
```sh
# fgst - pick files from `git status -s`
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fgst() {
# "Nothing to see here, move along"
is_in_git_repo || return
local cmd="${FZF_CTRL_T_COMMAND:-"command git status -s"}"
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" fzf -m "$@" | while read -r item; do
printf '%q ' "$item" | cut -d " " -f 2
done
echo
}
```
### JRNL
Suggested by [@windisch](https://github.com/windisch). Only tested under zsh.