#!/bin/sh # Help messages: LONG_USAGE="Select changed files using fzf and print to standard output." # Tell git-sh-setup we're ok with being in a subdir: SUBDIRECTORY_OK=1 . "$(git --exec-path)/git-sh-setup" # Make sure we're in a working tree require_work_tree_exists # Jump to top level so we can use $PWD below to print absolute paths # (this seems easier than trying to figure out relative paths from # porcelained git-status output): cd_to_toplevel # -z does NUL-terminated outputs, puts new filenames first for renamed files, # etc. -u includes untracked files. git status -u -z --porcelain | \ # Take from the 4th character up to end-of-line (first 3 are status chars): cut -z -c4- | \ # IFF we're inside a tmux, fzf-tmux will pop up in a separate pane: fzf-tmux --multi --read0 --print0 | \ # This is ridiculous, but I never know how to combine stdin and args: xargs -0 -I{} -n1 echo "$PWD/{}"