Anthony Rodriguez
dc7ee4d021
Add .config/fish/functions/_fzf_extract_var_info.fish Add .config/fish/functions/_fzf_preview_changed_file.fish Add .config/fish/functions/_fzf_preview_file.fish Add .config/fish/functions/_fzf_report_diff_type.fish Add .config/fish/functions/_fzf_report_file_type.fish Add .config/fish/functions/_fzf_search_directory.fish Add .config/fish/functions/_fzf_search_git_log.fish Add .config/fish/functions/_fzf_search_git_status.fish Add .config/fish/functions/_fzf_search_history.fish Add .config/fish/functions/_fzf_search_processes.fish Add .config/fish/functions/_fzf_search_variables.fish Add .config/fish/functions/_fzf_wrapper.fish Add .config/fish/functions/_nvm_index_update.fish Add .config/fish/functions/_nvm_list.fish Add .config/fish/functions/_nvm_version_activate.fish Add .config/fish/functions/_nvm_version_deactivate.fish Add .config/fish/functions/fish_greeting.fish Add .config/fish/functions/fish_mode_prompt.fish Add .config/fish/functions/fish_title.fish Add .config/fish/functions/fzf_configure_bindings.fish Add .config/fish/functions/nvm.fish
36 lines
1.7 KiB
Fish
36 lines
1.7 KiB
Fish
function _fzf_search_git_log --description "Search the output of git log and preview commits. Replace the current token with the selected commit hash."
|
|
if not git rev-parse --git-dir >/dev/null 2>&1
|
|
echo '_fzf_search_git_log: Not in a git repository.' >&2
|
|
else
|
|
if not set --query fzf_git_log_format
|
|
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
|
|
set -f fzf_git_log_format '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)'
|
|
end
|
|
|
|
set -f preview_cmd 'git show --color=always --stat --patch {1}'
|
|
if set --query fzf_diff_highlighter
|
|
set preview_cmd "$preview_cmd | $fzf_diff_highlighter"
|
|
end
|
|
|
|
set -f selected_log_lines (
|
|
git log --no-show-signature --color=always --format=format:$fzf_git_log_format --date=short | \
|
|
_fzf_wrapper --ansi \
|
|
--multi \
|
|
--scheme=history \
|
|
--prompt="Git Log> " \
|
|
--preview=$preview_cmd \
|
|
--query=(commandline --current-token) \
|
|
$fzf_git_log_opts
|
|
)
|
|
if test $status -eq 0
|
|
for line in $selected_log_lines
|
|
set -f abbreviated_commit_hash (string split --field 1 " " $line)
|
|
set -f full_commit_hash (git rev-parse $abbreviated_commit_hash)
|
|
set -f --append commit_hashes $full_commit_hash
|
|
end
|
|
commandline --current-token --replace (string join ' ' $commit_hashes)
|
|
end
|
|
end
|
|
|
|
commandline --function repaint
|
|
end
|