Closed dagadbm closed 2 years ago
@dagadbm is git_status
what you're looking for?
just searched. its not the same thing because that is per file right and more related to patch add and so on (so something similar to git signs that allows you add/reset changes.
What I am talking about is basically a find_files filtered by currently changed files (as in if you do a git status you would see the untracked/unstaged files to change. Same as :GFiles? from fzf.vim
I am probably missing something obvious here, as from my point of view they do exactly the same thing? They show changed files, where preview is the actual changes. You can fuzzy find by the name of the file, and pressing <CR>
would open up the file. What exact behavior is missing from Telescope?
From what I can see (just started with Telescope), git_status
returns only modified files since HEAD
, not all modified files on the current branch.
This works for me (improvements welcome) - I have this shell script in /home/USER/bin/_private/nvim-telscope-scripts
:
git-branch-modified.sh
BRANCH="$PROJECT_MAIN_BRANCH"
if [[ -z "$BRANCH" ]]; then
BRANCH="master"
fi
if [[ "$1" == "list" ]]; then
git diff --name-only --diff-filter=ACMR --relative $BRANCH
elif [[ "$1" == "diff" ]]; then
git diff --diff-filter=ACMR --relative $BRANCH "$2"
fi
And use this for Telescope:
changed_on_branch = function()
local previewers = require('telescope.previewers')
local pickers = require('telescope.pickers')
local sorters = require('telescope.sorters')
local finders = require('telescope.finders')
pickers.new {
results_title = 'Modified on current branch',
finder = finders.new_oneshot_job({'/home/USER/bin/_private/nvim-telscope-scripts/git-branch-modified.sh', 'list'}),
sorter = sorters.get_fuzzy_file(),
previewer = previewers.new_termopen_previewer {
get_command = function(entry)
return {'/home/USER/bin/_private/nvim-telscope-scripts/git-branch-modified.sh', 'diff', entry.value}
end
},
}:find()
end
Hey everyone,
FZF git_files implementation actually only shows the changed files on your current branch. This makes it easy to cycle through files you have changed and want to see.
Would it be possible to add an optional argument to git_files to allow for this behavior?