diff --git a/Examples.md b/Examples.md index f96513f..e572f57 100644 --- a/Examples.md +++ b/Examples.md @@ -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.