Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
924 B

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